When using standard library APIs added in 1.17 (Time.UnixMilli() in my case), I had hoped that the toolchain would ask me to update the go directive in the go mod file, exactly as it did when adding go:embed directives.
$ cat go.mod
$ go run time/main.go
$ go run embed/main.go
embed/main.go:8:3: go:embed requires go1.16 or later (-lang was set to go1.15; check go.mod)
What did you expect to see?
I thought that the toolchain would ask me to modify the go version, exactly as it did with usage of go:embed
time/main.go:9: Time.UnixMilli() requires go1.17 or later (-lang was set to go1.15; check go.mod)
What did you see instead?
The module builds, and passes go mod tidy and go mod vet without any issue, despite incorrectly setting the go version in the mod file.
Apologies if this is a duplicate, I spent some time searching but I wasn't able to find an issue matching this request. The closest I found was #30241
The text was updated successfully, but these errors were encountered:
Also #46201 and #30791; depending on the definition, it could be interpreted that the only purpose of the version is to enable new language/toolchain features (and that it's legal to use newer versions in go.mod but still support older versions of Go with the right build tags, including new APIs/packages/etc).