loader: use name "main" for the main package

This should make exported names a bit more consistent.

I believe there was a bug report for this issue, but I can't easily find
it. In any case, I think it's an important improvement to match the
behavior of the Go toolchain.
This commit is contained in:
Ayke van Laethem
2021-01-13 17:00:08 +01:00
committed by Ron Evans
parent c4d642007e
commit dbc438b2ae
2 changed files with 13 additions and 3 deletions
+2 -2
View File
@@ -67,7 +67,7 @@ func NewProgram(lprogram *loader.Program) *Program {
program := lprogram.LoadSSA()
program.Build()
mainPkg := program.ImportedPackage(lprogram.MainPkg().ImportPath)
mainPkg := program.Package(lprogram.MainPkg().Pkg)
if mainPkg == nil {
panic("could not find main package")
}
@@ -79,7 +79,7 @@ func NewProgram(lprogram *loader.Program) *Program {
}
for _, pkg := range lprogram.Sorted() {
p.AddPackage(program.ImportedPackage(pkg.ImportPath))
p.AddPackage(program.Package(pkg.Pkg))
}
return p