On Friday, 3 September 2021 at 02:18:54 UTC+2 Connor Kuehl wrote: > But this whole time as I've been learning the language, the standard > packages can be imported without any explicit prefix: > > import "fmt" > > and I found a go.mod in my Go distribution's standard library [1], so > that suggests to me that the standard library is implemented as a module > too. >
That assumption is a bit wrong, or at least the conclusion drawn are not suitable. The stdlib is part of the Go installation and not a "real" module: Modules are used to track dependencies and select versions of dependencies. Any single Go installation needs _exactly_ the stdlib provided by the installation and you cannot use a "different version" of the stdlib than the one distributed in the installation of Go itself. That's why the stdlib is not a "module" for your projects. But the Go installation itself needs other code and that code is tracked as normal dependencies via modules that's why you'll find several go.mod in the source tree of Go. The fact that stdlib packages have short import paths predates modules by a decade, is convenient and nothing would be gained by typing import "golang.org/std/strings" everywhere. It might even be misleading as you neither can replace or require versions of this hypothetical golang.org/std module via the go.mod file of your project. The stdlib is not an external dependency to your code. V. -- 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/80cb9d28-a582-400c-bdcf-1d4667e8cb98n%40googlegroups.com.