go mod tidy fails in older version of Go if new stdlib package is imported #43400
Labels
FrozenDueToAge
GoCommand
cmd/go
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I've made a package that was importing new go1.16
embed
and guarded that import with// +build go1.16
, I've also implemented alternative for older versions of Go in the same package and guarded it with// +build !go1.16
.The code passes the build in both
go1.15
andgotip
(orgo1.16beta1
). However there is a problem when I rungo mod vendor
orgo mod tidy
.Here is a minimal reproducer: https://play.golang.org/p/1MAM92BgVOT
What did you expect to see?
What did you see instead?
I would like to be able to write code for upcoming Go features in advance, but at the same time I'd like to keep module management safe in older versions of Go. For library development I can switch to
gotip
, but apps that use the library would still run on stable version, and they would suffer from failinggo mod tidy
during own development.The text was updated successfully, but these errors were encountered: