'what does //go:build xxx and // +build xxx means in golang? [duplicate]
I always see the code,
//go:build linux
// +build linux
what mean? I don't understand.
just give me some examples
Solution 1:[1]
These are build constraints, see https://pkg.go.dev/go/build#hdr-Build_Constraints
In older versions of Go, you would say
// +build linux
where the new syntax from Go 1.17 and up is
//go:build linux
but they do the same thing: only include this file in the Linux build.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | gonutz |
