Articles by Tuan Nguyen
How to use goroutine return value? [SOLVED]
In this example we will use golang channel to fetch the goroutine return value:
How to PROPERLY stop goroutine? [SOLVED]
In today's article, I will guide you on how to stop a goroutine in Golang. A goroutine is a very lightweight thread that is managed by the Go runtime. Every
How to change int to int64 in Golang? [SOLVED]
In Golang, it is very simple to convert an int to int64. In today's post, we will show you some simple examples of converting an int to int64. Depending on
Golang iterate over slice in reverse? [SOLVED]
In Golang, iterating over a slice is surprisingly straightforward; In this article, we will learn how to iterate over a slice in reverse in Go.
Golang search for an element in slice [SOLVED]
In this tutorial, we will try to implement some algorithms to search for an element in a slice. Go before version 1.18 does not provide any built-in methods
How to write logs to file in Golang? [SOLVED]
In this tutorial, we will learn how to write logs to file in Golang. We have several ways to save the application log to specific files: we can use the
Print Function, File Name, Line Number in GO [SOLVED]
In this tutorial we will share different methods to print or get logrus line number, file name, function name of the go code.
How to get current time in milliseconds in GO? [SOLVED]
In this tutorial, we will try to get Unix time in milliseconds from a time.Time in Golang. The built-in time package provides some functions to help us to
How to handle defer calls with os.Exit in GO? [SOLVED]
In this tutorial, we will guide you on how to handle defer calls with the os.Exit(). The defer keyword in Go is a statement used to defer the execution of a
Golang Padding String, Int or Float [SOLVED]
In this tutorial we have covered different examples for golang padding or formatting of string and integer values. We can perform formatting using whitespace or …
How to pass multiple values into URL in GO? [SOLVED]
When building an HTTP server and client, we might need to pass multiple strings as parameters to an HTTP URL. In this tutorial, we will introduce some methods
How to use go get specific version in GO? [SOLVED]
In this tutorial, we will show you how to import a package on a specific version. Your code may occasionally require extra functions not available in your
How to set golang HTTP client timeout? [SOLVED]
In this tutorial, we will explain some methods to set timeout for HTTP requests. A Request Timeout header is defined for Hypertext Transfer Protocol (HTTP).
Subtract time.Duration from time in GO [SOLVED]
In Golang, we usually have to deal with time management, we do need to do some operations such as adding, and subtracting a duration from time. We will walk
Cannot find package even if GOPATH is set [SOLVED]
Sometimes you will encounter the "Cannot find package" error (even though GOPATH is set) when building a Golang module. In this article, we will explain why
