Go

Remove source path from Go’s panic stack trace

I would like to share the Golang’s build flag to remove the source path (GOPATH) from panic stack trace output. In production environments or commercial projects it is sometimes not ideal to display the source path because of privacy, security or other reasons. Below is an example of a stack trace output that reveals the […]

Continue Reading…

Generate text to image in Go

In this blog post I will share how to generate text to image in Go programming language (Golang). I have previous and similar blog post using Python. You can check that post here. The reasons why I created this application is for me to share text content like Linux configuration and source code snippet in […]

Continue Reading…

Controller Request Mapping in Golang

Background I’ve been developing web applications using Java and Spring Framework and in 2019, I started using Golang in some of my projects. So far my experience with Golang is great but I miss the annotation that Spring framework provides particularly the @RequestMapping for URL mapping, @Bean and @Autowired for dependency injection. Most of the […]

Continue Reading…

Linux systemd for your Go application

Systemd is a Linux software suite that handles system services (daemon) and timers; it enables you to start, stop and restart your application using systemctl command. It can also start your application during operating systems boot-up sequence. Note that you will need to have root or sudo privileges for this operation. To create a systemd […]

Continue Reading…

Golang Linux Daemon

You build your first Golang web application and running in a remote server via SSH. The problem with that is once the SSH session is terminated it also kill any running programs associated with that SSH session. Using nohup solves this problem but I think this is okay during development and testing phase. A better […]

Continue Reading…

Generate a self-signed certificate for Golang

Use OpenSSL generate a self-signed certificate for Golang. In this code snippetI created a certificate with validity of 15 years. openssl genrsa -out server.key 2048 openssl req -new -x509 -sha256 -key server.key -out server.crt -days 5475 Once you create the certificate and key you can use it in your Golang HTTP like this log.Fatal(http.ListenAndServeTLS(“:”+port, configuration.HTTP.ServerCert, […]

Continue Reading…

Randomly create a time.Sleep in Golang

To randomly create a time.Sleep in Golang you can use the code snippet below. You may want to simulate a load in your web server and have an arbitrary seconds or minutes before getting the reply. rand.Seed(time.Now().UnixNano()) delta := rand.Intn(60 + 1) // randomly generates numbers 1 to 60 time.Sleep(time.Duration(delta) * time.Second) // sleep and […]

Continue Reading…

Golang SQLite Simple Example

In this post, I will show you a simple example how to use SQLite in Golang. SQLite is one of the popular embedded, file-based database in the market used by companies like Apple, Airbus, Google, Skype, Autodesk and Dropbox. You can checkout the list of well-know SQLite user in this link https://www.sqlite.org/famous.html Requirements Knowledge in […]

Continue Reading…

Using reCAPTCHA with Golang

Overview Google’s reCAPTCHA is one of the tool we can use to stop malicious internet bots from abusing our web applications.It comes in two versions, reCAPTCHA v2 and v3. Version 3 uses a score based and no-interaction approach to handle bots from humans. Version 2 uses use a checkbox that will require users to answer […]

Continue Reading…

Develop a whatismyipaddress.com clone website using Golang

Do you want to build a website clone similar to whatismyipaddress.com? It is actually easy to develop. I decided to create this tool because I was working on an automated DNS client that will check my public IP address. Perhaps, somebody might need this in the future. I already made the completed demo available online […]

Continue Reading…