Reputation: 55
I found // +build OMIT
in this page https://blog.golang.org/context/server/server.go
I know what a build constraint is.
OMIT
isn't
GOOS
or GOARCH
valuecgo
go1.12
Does it literally mean "omit something here" as // +build ignore
keeps a file from being considered for the build ?
Upvotes: 0
Views: 804
Reputation:
The source file is ignored when the the build tag OMIT
is not specified. It works the same way as ignore
. The OMIT
and ignore
tags have no special meaning to the build tools.
The file is included in the blog post using the present package .code command. The .code command ignores source file lines ending with OMIT
.
In summary, two things are going on. The build constraint is used to ignore the file. The tag OMIT
is used instead of the more common ignore
so that the build constraint does not appear in the blog post.
The program is run using go run server.go
. The go run
command ignores build constraints.
Upvotes: 2