@@ -1846,6 +1846,14 @@ func (p *Package) load(ctx context.Context, opts PackageOpts, path string, stk *
1846
1846
stk .Push (path )
1847
1847
defer stk .Pop ()
1848
1848
1849
+ mainPath := p .ImportPath
1850
+ if p .Internal .CmdlineFiles {
1851
+ mainPath = "command-line-arguments"
1852
+ }
1853
+ if cfg .ModulesEnabled {
1854
+ p .Module = modload .PackageModuleInfo (ctx , mainPath )
1855
+ }
1856
+
1849
1857
p .EmbedFiles , p .Internal .Embed , err = resolveEmbed (p .Dir , p .EmbedPatterns )
1850
1858
if err != nil {
1851
1859
p .Incomplete = true
@@ -1905,6 +1913,10 @@ func (p *Package) load(ctx context.Context, opts PackageOpts, path string, stk *
1905
1913
p .Internal .Imports = imports
1906
1914
p .collectDeps ()
1907
1915
1916
+ if cfg .ModulesEnabled && p .Error == nil && p .Name == "main" && len (p .DepsErrors ) == 0 {
1917
+ p .Internal .BuildInfo = modload .PackageBuildInfo (mainPath , p .Deps )
1918
+ }
1919
+
1908
1920
// unsafe is a fake package.
1909
1921
if p .Standard && (p .ImportPath == "unsafe" || cfg .BuildContext .Compiler == "gccgo" ) {
1910
1922
p .Target = ""
@@ -1944,17 +1956,6 @@ func (p *Package) load(ctx context.Context, opts PackageOpts, path string, stk *
1944
1956
setError (fmt .Errorf ("Fortran source files not allowed when not using cgo or SWIG: %s" , strings .Join (p .FFiles , " " )))
1945
1957
return
1946
1958
}
1947
-
1948
- if cfg .ModulesEnabled && p .Error == nil {
1949
- mainPath := p .ImportPath
1950
- if p .Internal .CmdlineFiles {
1951
- mainPath = "command-line-arguments"
1952
- }
1953
- p .Module = modload .PackageModuleInfo (ctx , mainPath )
1954
- if p .Name == "main" && len (p .DepsErrors ) == 0 {
1955
- p .Internal .BuildInfo = modload .PackageBuildInfo (mainPath , p .Deps )
1956
- }
1957
- }
1958
1959
}
1959
1960
1960
1961
// An EmbedError indicates a problem with a go:embed directive.
0 commit comments