March 2020
Intermediate to advanced
406 pages
8h 39m
English
If you'd like to add a build constraint to your Go build, you can add a comment line at the beginning of the file that's only preceded by blank lines and other comments. The form of this comment is // +build darwin,amd64,!cgo, android,386,cgo.
This corresponds to a boolean output of darwin AND amd64 AND (NOT cgo)) OR (android AND 386 AND cgo.
This needs to proceed with the package declaration with a newline between the build constraint and the package initialization. This takes the following form:
// +build [OPTIONS]package main
The complete list of build constraints can be found at https://golang.org/pkg/go/build/#hdr-Build_Constraints. This list includes the following build constraints:
Read now
Unlock full access