December 2021
Intermediate to advanced
510 pages
11h 20m
English
By default, the go build tool builds an executable binary for the current operating system and architecture. You can also use go build to build your command-line tool for a different platform even if you don’t have access to that platform. For example, if you’re using Linux, you can build a Windows or macOS binary that can be executed on those platforms without Go installed. This process is called cross-compilation. Let’s build the word counter tool for the Windows platform by setting the GOOS environment variable to windows before running the build tool:
| | $ GOOS=windows go build |
| | $ ls |
| | go.mod main.go main_test.go wc wc.exe |
Use the file command to get information about the new wc.exe ...
Read now
Unlock full access