On Tue, Oct 24, 2017 at 8:14 PM, Alex Buchanan <buchanae.o...@gmail.com> wrote: > > Is there documentation (or other) explaining why the main package must have > name "main" and may not be imported? Is this an important simplification for > the compiler?
The language spec says that the main package must have the name main. I guess we could use other mechanisms but that one seems reasonable to me. cmd/compile prohibiting `import "main"` is a moderately important simplification because cmd/compile uses the import path to set symbol names, and for the main package it uses "main". If cmd/compile permitted `import "main"` then there would be two different packages with the same import path, which can't work. So it would have to use something else for the imported "main", but what? Note that cmd/compile does not prohibit importing a package named "main" if the path used to import that package is not specifically "main". But I think the go tool does prohibit that, and I think that is simply to be less surprising to most people. 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. For more options, visit https://groups.google.com/d/optout.