Print Current Memory Usage
In this post we show how you can print the state of the current memory usage in Go. To do this, we’ve created a function PrintMemUsage() to help out, so you can call this when ever you need to know. All the info we need can be acquired through the runtime package, which allows us to read the state of the memory into the MemStats struct. It returns stats like how much memory the program is using, how much of it the OS has allocated to it and the number of garbage collections.
Convert HEIC to JPG in Go
The “High Efficiency Image File Format” or HEIF is an image format often used by Apple devices. Although called HEIF, the file types are often heic (presumably the ‘c’ stands for container?) They use a similar encoding method of video formats and are deemed better quality and lower file size than standard jpeg files. In our example, we’re trying to convert these heic files back into jpg files though - so we can use them elsewhere, display them or what ever we choose.
Sleeping in Golang
Sleeping in Go and how to pause execution and sleep for a number of seconds in Go (golang). We can use the time package from the standard library to sleep for a duration of time. You can use any duration of time, providing you use the constants provided. In our example below we sleep for two seconds, and to illustrate the point, we print out the time before and after we do this.
Install Latest Version of Go (Linux/OSX)
This article describes how to install the latest version of Go (golang). It also helpfully updates itself by pulling the latest version numbers directly, so you don’t have to go and dig out the latest version each time they release a version (yay!) - just copy and paste away. For more info, try their installer docs.