Overview: os/exec package can be used to trigger any OS command from Go. The same can be used for triggering .sh file. First, create a sample.sh file in the same directory. Make…
Author: admin
Create an empty file in Go (Golang)
Overview os.Create() can be used to create an empty file in go. The signature of the function is Basically this function Create a named file with mode 0666 It truncates the file…
Download an image or file from a URL in Go (Golang)
Overview Below are the steps to download an image or a file from a URL use http.Get(URL) function to get the bytes of the file from the URL. Create an empty file…
Server Error – 500 vs 502 vs 503 vs 504
Overview All 5XX errors are server errors. In this article, we will learn about the difference between all of them. In this article, we use the term proxy/gateway server. Some of the…
Generate a UUID/GUID in Go (Golang)
UUID also known as GUID is a 16 byte or 128-bit number. It is meant to uniquely identify something. Some of the properties of UUID are UUID is likely to be different…
Check if an IP address is IPV4 or IPV6 in Go (Golang)
IPV4 address is of 4 bytes string with each byte separated by dot (‘.’) IPV6 address is 8 groups of 4 hexagonal digits separated by colon (‘:’) The below code Prints invalid…
Validate an IP address in GO
ParseIP function of the net package can be used to validate an IP address. The same function can be used to validate both IPV4 and IPV6 addresses. Below is the signature of…
channel as function argument in Go (Golang)
Overview There are many ways in which a channel can be passed as a function argument. The direction of the arrow for a channel specifies the direction of flow of data chan…
Create a new time instance in Go (Golang)
In Go time.Time struct is used to represent an instance of time or date. Below are three ways of creating a new time instance Using time.Now() time.Now() function can be used to…
All data types in Golang with examples
Note: If you are interested in learning Golang, then for that we have a golang comprehensive tutorial series. Do check it out – Golang Comprehensive Tutorial Series. Now let’s see the current tutorial….