Re: [go-nuts] Unintuitive error message for external modules that lack a go.mod

2024-10-22 Thread rojiu
The version I'm using is go1.22.6. To reproduce the issue, I created a repository. This repository does not contain a go.mod, but it could still be imported. Since the modules within the same repository can be used without placing a go.mod in each of them, I mistakenly thought that an external

Re: [go-nuts] Unintuitive error message for external modules that lack a go.mod

2024-10-22 Thread Ian Lance Taylor
On Tue, Oct 22, 2024 at 8:39 AM rojiu 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-nuts] Unintuitive error message for external modules that lack a go.mod

2024-10-22 Thread rojiu
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, t