I ran into this error when trying to create a module with a single Go file 
and import it from GitHub:

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

After some digging, I learned that since Go 1.18, external modules need a 
go.mod file. Without one, the language spec defaults to Go 1.16. The tricky 
part is, it's not obvious at first glance that this error is caused by a 
missing go.mod file in the module you're trying to import. I was thrown off 
because the go.mod file in my main project had 'go 1.22.6' in it. It'll be 
helpful if the error message could specifically mention that it's looking 
for a go.mod file in the module being imported. What do you think?

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/64ffaef2-40ee-4654-a0d2-515b578ce3c4n%40googlegroups.com.

Reply via email to