I'm working on this PR(https://github.com/gin-contrib/i18n/pull/7) and it uses embed package which was supported from go 1.16(https://tip.golang.org/doc/go1.16#library-embed). As the gin-contrib/i18n package support go version from go 1.13, I want to make it skip build and test for embed if go version < 1.16. What should I do? I tried using build tag like
//go:build go1.16
but this approach doesn't work as I expected. Thanks in advance.
CodePudding user response:
as mentioned in the docs. //go:build
constraint is included in Go 1.16, use also // build go1.16
.
This package parses both the original “// build” syntax and the “//go:build” syntax that will be added in Go 1.17. The parser is being included in Go 1.16 to allow tools that need to process Go 1.17 source code to still be built against the Go 1.16 release. See https://golang.org/design/draft-gobuild for details about the “//go:build” syntax.