mirror of
https://github.com/golang/go
synced 2024-11-17 00:34:48 -07:00
cmd/go/internal/modload: fix sanity check in rawGoModSummary
m.Path is never empty for a module in the build list; this fixes a typo from CL 334932. Change-Id: I5328081ba3bcf5eeac9a1b21a03969ba82ab20ab Reviewed-on: https://go-review.googlesource.com/c/go/+/489076 Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com>
This commit is contained in:
parent
bc04d4afa2
commit
917171f564
@ -673,10 +673,15 @@ func goModSummary(m module.Version) (*modFileSummary, error) {
|
||||
// ignoring all replacements that may apply to m and excludes that may apply to
|
||||
// its dependencies.
|
||||
//
|
||||
// rawGoModSummary cannot be used on the Target module.
|
||||
// rawGoModSummary cannot be used on the main module outside of workspace mode.
|
||||
func rawGoModSummary(m module.Version) (*modFileSummary, error) {
|
||||
if m.Path == "" && MainModules.Contains(m.Path) {
|
||||
panic("internal error: rawGoModSummary called on the Target module")
|
||||
if m.Version == "" && !inWorkspaceMode() && MainModules.Contains(m.Path) {
|
||||
// Calling rawGoModSummary implies that we are treating m as a module whose
|
||||
// requirements aren't the roots of the module graph and can't be modified.
|
||||
//
|
||||
// If we are not in workspace mode, then the requirements of the main module
|
||||
// are the roots of the module graph and we expect them to be kept consistent.
|
||||
panic("internal error: rawGoModSummary called on a main module")
|
||||
}
|
||||
return rawGoModSummaryCache.Do(m, func() (*modFileSummary, error) {
|
||||
summary := new(modFileSummary)
|
||||
@ -724,19 +729,18 @@ var rawGoModSummaryCache par.ErrCache[module.Version, *modFileSummary]
|
||||
// rawGoModData returns the content of the go.mod file for module m, ignoring
|
||||
// all replacements that may apply to m.
|
||||
//
|
||||
// rawGoModData cannot be used on the Target module.
|
||||
// rawGoModData cannot be used on the main module outside of workspace mode.
|
||||
//
|
||||
// Unlike rawGoModSummary, rawGoModData does not cache its results in memory.
|
||||
// Use rawGoModSummary instead unless you specifically need these bytes.
|
||||
func rawGoModData(m module.Version) (name string, data []byte, err error) {
|
||||
if m.Version == "" {
|
||||
// m is a replacement module with only a file path.
|
||||
|
||||
dir := m.Path
|
||||
if !filepath.IsAbs(dir) {
|
||||
if inWorkspaceMode() && MainModules.Contains(m.Path) {
|
||||
dir = MainModules.ModRoot(m)
|
||||
} else {
|
||||
// m is a replacement module with only a file path.
|
||||
dir = filepath.Join(replaceRelativeTo(), dir)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user