Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

go

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
like image 867
Jonathan Kittell Avatar asked Oct 28 '25 13:10

Jonathan Kittell


1 Answers

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

like image 51
Jonathan Kittell Avatar answered Oct 30 '25 10:10

Jonathan Kittell