]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/modload: remove likely vestigial ability to infer module path from...
authorthepudds <thepudds1460@gmail.com>
Wed, 9 Apr 2025 21:43:14 +0000 (17:43 -0400)
committerGopher Robot <gobot@golang.org>
Tue, 20 May 2025 14:58:55 +0000 (07:58 -0700)
CL 518776 deleted the cmd/go/internal/modconv package and dropped the
ability to import dependency requirements from ~nine or so legacy
pre-module dependency configuration files. Part of the rationale from
Russ in 2023 for dropping that support was that "by now no one is
running into those configs anymore during 'go mod init'".

For two of those legacy file formats, Godeps.json and vendor.json, the
ability to import their listed dependencies was dropped in CL 518776,
but what remained for those two formats was the ability to guess the
resulting module name in the absence of a name being supplied to 'go mod
init'.

This could be explained by the fact that this smaller functionality for
guessing a module name was separate, did not rely on the deleted modconv
package, and instead only relied on simple JSON parsing.

The name guessing was helpful as part of the transition when module
support was initially released, but it was never perfect, including the
various third-party dependency managers did not all have the same naming
rules that were enforced by modules.

In short, it is very unlikely anyone is relying on this now, so we
delete it.

This CL was spawned from discussion in two related documentation CLs
(CL 662675 and CL 662695).

Updates #71537

Change-Id: I9e087aa296580239562a0ecee58913c5edc533ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/664315
Reviewed-by: Michael Matloob <matloob@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Sam Thanawalla <samthanawalla@google.com>

src/cmd/go/internal/modload/init.go
src/cmd/go/testdata/script/mod_find.txt

index 20daf613509e6c27aeb3adc33b2e27bd80e92b86..3cf447e648ce4ee557998a9ff624c4da2956c368 100644 (file)
@@ -7,7 +7,6 @@ package modload
 import (
        "bytes"
        "context"
-       "encoding/json"
        "errors"
        "fmt"
        "internal/godebugs"
@@ -1747,22 +1746,6 @@ func findModulePath(dir string) (string, error) {
                }
        }
 
-       // Look for Godeps.json declaring import path.
-       data, _ := os.ReadFile(filepath.Join(dir, "Godeps/Godeps.json"))
-       var cfg1 struct{ ImportPath string }
-       json.Unmarshal(data, &cfg1)
-       if cfg1.ImportPath != "" {
-               return cfg1.ImportPath, nil
-       }
-
-       // Look for vendor.json declaring import path.
-       data, _ = os.ReadFile(filepath.Join(dir, "vendor/vendor.json"))
-       var cfg2 struct{ RootPath string }
-       json.Unmarshal(data, &cfg2)
-       if cfg2.RootPath != "" {
-               return cfg2.RootPath, nil
-       }
-
        // Look for path in GOPATH.
        var badPathErr error
        for _, gpdir := range filepath.SplitList(cfg.BuildContext.GOPATH) {
index 9c2037b6e0fc644749ba2e77b4b0613d8b2f30e4..748713cdf37c0c8ddb760b5bcf814327b2c6dcf1 100644 (file)
@@ -24,12 +24,6 @@ cp $devnull go.mod # can't use touch to create it because Windows
 ! go mod init
 stderr 'go.mod already exists'
 
-# Module path from Godeps/Godeps.json overrides GOPATH.
-cd $GOPATH/src/example.com/x/y/z
-go mod init
-stderr 'unexpected.com/z'
-rm go.mod
-
 # Empty directory outside GOPATH fails.
 mkdir $WORK/empty
 cd $WORK/empty