Writing OS-Specific code with build tags

A common issue I encounter while writing a Go library is managing multi-platform support. The first libraries I built had terrible cross-platform compatibility. However, this was a result of some bad code. For example, I joined file path strings with the + operator. This resulted in some functionality not working altogether. I did manage to fix the issue though. I imported package file/filepath , which already supports multiple OS environments, to correct the issue. In this post, I’ll attempt to write a library. This library will check to see if a certain program is installed. I chose this problem as Windows and Unix-based operating systems place programs in different file locations.

Read more