预声明的任何要求 go1.18 或更高版本(-lang 设置为 go1.16;请检查 go.mod)

huangapple go评论107阅读模式
英文:

predeclared any requires go1.18 or later (-lang was set to go1.16; check go.mod)

问题

导入了一个包含泛型的模块,现在我的代码报错要检查是否运行的是1.18或更高版本的go.mod。我的代码和被导入的模块都有一个go.mod文件,其中写着1.20版本。如果两个模块的go.mod都是1.20版本,为什么会报这个错误呢?

错误信息如下:

type parameter requires go1.18 or later (-lang was set to go1.16; check go.mod)

两个go.mod文件都是1.20版本:

go 1.20
英文:

Imported a module that has generics and now my code is throwing an error to check if go.mod is running 1.18 or later. Both my code and the module that was imported has go.mod file that says 1.20. If both modules have version 1.20 in go.mod why does it throw this error?

 type parameter requires go1.18 or later (-lang was set to go1.16; check go.mod)

Both go.mod files have version 1.20

go 1.20

答案1

得分: 1

经过一个小时,我运行了模块的另一个更新,这次我注意到另一个模块似乎已经升级了。

go: upgraded github.com/mattn/go-isatty v0.0.17 => v0.0.18

不确定这是如何升级的,但它确实升级了。也许从其他包获取更新需要时间,或者go mod有一些方法可以知道要升级什么。

我不再收到关于go.mod版本1.18或更高的错误。

jonathan.kittell@Jonathan-Kittell's-MacBook-Pro demo % go get -u all
go: downloading github.com/mattn/go-isatty v0.0.18
go: downloading github.com/jkittell/datastructures v0.0.0-20230420174618-e379a55b9a3c
go: upgraded github.com/jkittell/datastructures v0.0.0-20230420173253-66732def1378 => v0.0.0-20230420174618-e379a55b9a3c
go: upgraded github.com/mattn/go-isatty v0.0.17 => v0.0.18

英文:

After an hour I ran another update of the modules and this time I noticed another module appears to have gotten upgraded.

go: upgraded github.com/mattn/go-isatty v0.0.17 => v0.0.18

Not sure how this got upgraded but it did. Maybe it takes time to get the updates from other packages. Or go mod has some method of knowing what to upgrade.

I'm no longer getting the error about go.mod version 1.18 or later.

jonathan.kittell@Jonathan-Kittell's-MacBook-Pro demo % go get -u all
go: downloading github.com/mattn/go-isatty v0.0.18
go: downloading github.com/jkittell/datastructures v0.0.0-20230420174618-e379a55b9a3c
go: upgraded github.com/jkittell/datastructures v0.0.0-20230420173253-66732def1378 => v0.0.0-20230420174618-e379a55b9a3c
go: upgraded github.com/mattn/go-isatty v0.0.17 => v0.0.18

huangapple
  • 本文由 发表于 2023年4月21日 02:00:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/76067007.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定