Closed
Description
have a program where I have three files:
workspace_16.go which contains // +build go1.16 and a go:embed
workspace_15.go // +build !go1.16
workspace.go
and a go.mod with
go 1.14
cmd/bw/workspace_16.go:64:3: go:embed requires go1.16 or later (-lang was set to go1.14; check go.mod)
expect it to build properly.
Activity
[-]go install / go.mod / go:embed / build tags don't play well together.[/-][+]cmd/go: go install / go.mod / go:embed / build tags don't play well together.[/+]jayconrod commentedon Jul 9, 2021
The
go
directive ingo.mod
is the problem here. It needs to bego 1.16
or higher.Closing since this seems like it's working as intended. Your
+build
tags look like they should work.But #30791 is related. The
go
directive is not all that well-documented or understood.james-lawrence commentedon Jul 10, 2021
@jayconrod I believe you misunderstood the problem. it doesn't build, the source code with the build tags should build properly for both go 1.14, 1.15, and 1.16. 1.16 isn't the minimum version. changing go.mod to use version 1.16 would prevent it from building with go 1.14.
edit: waiting on results from CI, I believe i may have made an erroneous assumption on the build failure based on local builds. =)
james-lawrence commentedon Jul 10, 2021
@jayconrod nm then, I stand corrected. the error in CI was from an import that didn't get autoremoved during save. sigh