On Tue, Oct 22, 2024 at 8:39 AM rojiu <azurecod...@gmail.com> wrote:
>
> 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.  Want to file a bug report at https://go.dev/issue ?  Be sure
to say exactly what you did and what Go version you are using.  It's
not immediately clear to me how you are importing a package that
doesn't have a go.mod file.

Ian

-- 
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 visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcXcw34vpUwEf2CfVhVz8XFQ84qv4V%3D3OnCcS0ptjFoxtQ%40mail.gmail.com.

Reply via email to