Using GOOS and GOARCH
When developing your command-line application, it is important to maximize the audience by developing for as many platforms as possible. However, you may also want to target just a particular set of operating systems and architectures. In the past, it was much more difficult to deploy to platforms that differed from the one you were developing on. In fact, developing on a macOS platform and deploying it on a Windows machine involved setting up a Windows build machine to build the binary. The tooling would have to be synchronized, and there would be other deliberations that made collaborative testing and distribution cumbersome.
Luckily, Golang has solved this by building support for multiple platforms directly into the language’s toolchain. As discussed in Chapter 7, Developing for Different Platforms, and Chapter 11, Custom Builds and Testing CLI Commands, we learned how to write platform-independent code and use the go build
command and build tags...