Golang:如何跳过特定版本的测试

Golang: How to skip test for specific go version

我正在处理这个 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)。 由于 gin-contrib/i18n 包支持从 go 1.13 开始的 go 版本,如果 go 版本 < 1.16,我想让它跳过构建和测试嵌入。我应该怎么办?我尝试使用

这样的构建标签
//go:build go1.16

但是这种方法并不像我预期的那样有效。提前致谢。

docs所述。 //go:build 约束包含在 Go 1.16 中,也可以使用 // +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.