import (
"bytes"
"context"
- "encoding/json"
"errors"
"fmt"
"internal/godebugs"
}
}
- // 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) {
! 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