To cross compile for Linux, we'll need a GCC or compatible compiler that can build Linux binary files. On macOS, the easiest platform to use is musl-cross (musl has many other advantages that you can read more about at www.etalabs.net/compare_libcs.html). On Windows, the linux-gcc package will be suitable. Let's work through the steps for each of these.
Cross compiling for Linux with CGo
To Linux from macOS
To install the dependencies for cross compiling for Linux, we'll use the Homebrew package manager again—see the previous sections or https://brew.sh/ for installation instructions. Using Homebrew, we'll install the appropriate packages by opening a Terminal and executing the following...