12

Cross-Compilation across Different Platforms

This chapter introduces the user to cross-compilation, a powerful feature of Go, across different platforms. While build automation tools exist, understanding how to cross-compile provides essential knowledge for debugging and customization when necessary. This chapter will explain the different operating systems and architectures that Go can compile and how to determine which is needed. After Go is installed in your environment, there is a command, go env, with which you can see all the Go-related environment variables. We will discuss the two major ones used for building: GOOS and GOARCH.

We will give examples of how to build or install an application for each major operating system: Linux, macOS, ...

Get Building Modern CLI Applications in Go now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.