Skip to content

Commit 40effca

Browse files
committed
cmd: pull in golang.org/x/mod@3a5865c
This change updates the cmd module's requirement on x/mod and vendors in the changes. This pulls in the following changes into our vendored copy of x/mod: golang.org/cl/351319: module: accept trailing slash in MatchPrefixPattern golang.org/cl/353749: semver: remove unused err field golang.org/cl/355630: x/mod: update requirement on x/crypto golang.org/cl/359412: modfile: rename directory directive to use Changes have been made in cmd/go renaming all uses of directory to use and fixing references to functions in x/mod/modfile to account for the changes in the last of thse CLs. For #45713 Change-Id: I9121d08f6e6b11838bca50e6cbd756baeeae867b Reviewed-on: https://go-review.googlesource.com/c/go/+/364114 Trust: Michael Matloob <[email protected]> Run-TryBot: Michael Matloob <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]>
1 parent 29ec902 commit 40effca

25 files changed

+112
-120
lines changed

src/cmd/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.18
55
require (
66
github.com/google/pprof v0.0.0-20211104044539-f987b9c94b31
77
golang.org/x/arch v0.0.0-20210923205945-b76863e36670
8-
golang.org/x/mod v0.6.0-dev.0.20210913215816-37dd6891021a
8+
golang.org/x/mod v0.6.0-dev.0.20211102181907-3a5865c02020
99
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
1010
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
1111
golang.org/x/tools v0.1.8-0.20211116011028-4adea5033c5c

src/cmd/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ golang.org/x/arch v0.0.0-20210923205945-b76863e36670 h1:18EFjUmQOcUvxNYSkA6jO9VA
99
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
1010
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa h1:idItI2DDfCokpg0N51B2VtiLdJ4vAuXC9fnCb2gACo4=
1111
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
12-
golang.org/x/mod v0.6.0-dev.0.20210913215816-37dd6891021a h1:gAiIC0JKDJwXAQFyqEYxROcAzeeh5ZTwWjKORCFuQxs=
13-
golang.org/x/mod v0.6.0-dev.0.20210913215816-37dd6891021a/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
12+
golang.org/x/mod v0.6.0-dev.0.20211102181907-3a5865c02020 h1:HjtpZuJcnSa+yHlL4Y5aypjDvbHkJne5FS8JRmKI2+I=
13+
golang.org/x/mod v0.6.0-dev.0.20211102181907-3a5865c02020/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
1414
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
1515
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
1616
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

src/cmd/go/alldocs.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/go/internal/modload/init.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ func loadWorkFile(path string) (goVersion string, modRoots []string, replaces []
565565
goVersion = wf.Go.Version
566566
}
567567
seen := map[string]bool{}
568-
for _, d := range wf.Directory {
568+
for _, d := range wf.Use {
569569
modRoot := d.Path
570570
if !filepath.IsAbs(modRoot) {
571571
modRoot = filepath.Join(workDir, modRoot)
@@ -606,7 +606,7 @@ func WriteWorkFile(path string, wf *modfile.WorkFile) error {
606606
func UpdateWorkFile(wf *modfile.WorkFile) {
607607
missingModulePaths := map[string]string{} // module directory listed in file -> abspath modroot
608608

609-
for _, d := range wf.Directory {
609+
for _, d := range wf.Use {
610610
modRoot := d.Path
611611
if d.ModulePath == "" {
612612
missingModulePaths[d.Path] = modRoot
@@ -620,7 +620,7 @@ func UpdateWorkFile(wf *modfile.WorkFile) {
620620
if err != nil {
621621
continue // Error will be reported if modules are loaded.
622622
}
623-
wf.AddDirectory(moddir, f.Module.Mod.Path)
623+
wf.AddUse(moddir, f.Module.Mod.Path)
624624
}
625625
}
626626

@@ -887,7 +887,7 @@ func CreateWorkFile(ctx context.Context, workFile string, modDirs []string) {
887887
}
888888
base.Fatalf("go: error parsing go.mod in directory %s: %v", dir, err)
889889
}
890-
workF.AddDirectory(ToDirectoryPath(dir), f.Module.Mod.Path)
890+
workF.AddUse(ToDirectoryPath(dir), f.Module.Mod.Path)
891891
}
892892

893893
UpdateWorkFile(workF)

src/cmd/go/internal/workcmd/edit.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ This reformatting is also implied by any other modifications that use or
3737
rewrite the go.mod file. The only time this flag is needed is if no other
3838
flags are specified, as in 'go mod editwork -fmt'.
3939
40-
The -directory=path and -dropdirectory=path flags
41-
add and drop a directory from the go.work files set of module directories.
40+
The -use=path and -dropuse=path flags
41+
add and drop a use directive from the go.work file's set of module directories.
4242
4343
The -replace=old[@v]=new[@v] flag adds a replacement of the given
4444
module path and version pair. If the @v in old@v is omitted, a
@@ -52,7 +52,7 @@ The -dropreplace=old[@v] flag drops a replacement of the given
5252
module path and version pair. If the @v is omitted, a replacement without
5353
a version on the left side is dropped.
5454
55-
The -directory, -dropdirectory, -replace, and -dropreplace,
55+
The -use, -dropuse, -replace, and -dropreplace,
5656
editing flags may be repeated, and the changes are applied in the order given.
5757
5858
The -go=version flag sets the expected Go language version.
@@ -74,7 +74,7 @@ writing it back to go.mod. The JSON output corresponds to these Go types:
7474
Replace []Replace
7575
}
7676
77-
type Directory struct {
77+
type Use struct {
7878
Path string
7979
ModulePath string
8080
}
@@ -106,8 +106,8 @@ func (f flagFunc) Set(s string) error { f(s); return nil }
106106
func init() {
107107
cmdEdit.Run = runEditwork // break init cycle
108108

109-
cmdEdit.Flag.Var(flagFunc(flagEditworkDirectory), "directory", "")
110-
cmdEdit.Flag.Var(flagFunc(flagEditworkDropDirectory), "dropdirectory", "")
109+
cmdEdit.Flag.Var(flagFunc(flagEditworkUse), "use", "")
110+
cmdEdit.Flag.Var(flagFunc(flagEditworkDropUse), "dropuse", "")
111111
cmdEdit.Flag.Var(flagFunc(flagEditworkReplace), "replace", "")
112112
cmdEdit.Flag.Var(flagFunc(flagEditworkDropReplace), "dropreplace", "")
113113

@@ -182,25 +182,25 @@ func runEditwork(ctx context.Context, cmd *base.Command, args []string) {
182182
modload.WriteWorkFile(gowork, workFile)
183183
}
184184

185-
// flagEditworkDirectory implements the -directory flag.
186-
func flagEditworkDirectory(arg string) {
185+
// flagEditworkUse implements the -use flag.
186+
func flagEditworkUse(arg string) {
187187
workedits = append(workedits, func(f *modfile.WorkFile) {
188188
_, mf, err := modload.ReadModFile(filepath.Join(arg, "go.mod"), nil)
189189
modulePath := ""
190190
if err == nil {
191191
modulePath = mf.Module.Mod.Path
192192
}
193-
f.AddDirectory(modload.ToDirectoryPath(arg), modulePath)
194-
if err := f.AddDirectory(modload.ToDirectoryPath(arg), ""); err != nil {
195-
base.Fatalf("go: -directory=%s: %v", arg, err)
193+
f.AddUse(modload.ToDirectoryPath(arg), modulePath)
194+
if err := f.AddUse(modload.ToDirectoryPath(arg), ""); err != nil {
195+
base.Fatalf("go: -use=%s: %v", arg, err)
196196
}
197197
})
198198
}
199199

200-
// flagEditworkDropDirectory implements the -dropdirectory flag.
201-
func flagEditworkDropDirectory(arg string) {
200+
// flagEditworkDropUse implements the -dropuse flag.
201+
func flagEditworkDropUse(arg string) {
202202
workedits = append(workedits, func(f *modfile.WorkFile) {
203-
if err := f.DropDirectory(modload.ToDirectoryPath(arg)); err != nil {
203+
if err := f.DropUse(modload.ToDirectoryPath(arg)); err != nil {
204204
base.Fatalf("go: -dropdirectory=%s: %v", arg, err)
205205
}
206206
})
@@ -287,8 +287,8 @@ func editPrintJSON(workFile *modfile.WorkFile) {
287287
if workFile.Go != nil {
288288
f.Go = workFile.Go.Version
289289
}
290-
for _, d := range workFile.Directory {
291-
f.Directory = append(f.Directory, directoryJSON{DiskPath: d.Path, ModPath: d.ModulePath})
290+
for _, d := range workFile.Use {
291+
f.Use = append(f.Use, useJSON{DiskPath: d.Path, ModPath: d.ModulePath})
292292
}
293293

294294
for _, r := range workFile.Replace {
@@ -304,12 +304,12 @@ func editPrintJSON(workFile *modfile.WorkFile) {
304304

305305
// workfileJSON is the -json output data structure.
306306
type workfileJSON struct {
307-
Go string `json:",omitempty"`
308-
Directory []directoryJSON
309-
Replace []replaceJSON
307+
Go string `json:",omitempty"`
308+
Use []useJSON
309+
Replace []replaceJSON
310310
}
311311

312-
type directoryJSON struct {
312+
type useJSON struct {
313313
DiskPath string
314314
ModPath string `json:",omitempty"`
315315
}

src/cmd/go/internal/workcmd/use.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func runUse(ctx context.Context, cmd *base.Command, args []string) {
5353
}
5454

5555
haveDirs := make(map[string]bool)
56-
for _, dir := range workFile.Directory {
56+
for _, dir := range workFile.Use {
5757
haveDirs[filepath.Join(filepath.Dir(gowork), filepath.FromSlash(dir.Path))] = true
5858
}
5959

@@ -105,10 +105,10 @@ func runUse(ctx context.Context, cmd *base.Command, args []string) {
105105
}
106106

107107
for dir := range removeDirs {
108-
workFile.DropDirectory(filepath.ToSlash(dir))
108+
workFile.DropUse(filepath.ToSlash(dir))
109109
}
110110
for dir := range addDirs {
111-
workFile.AddDirectory(filepath.ToSlash(dir), "")
111+
workFile.AddUse(filepath.ToSlash(dir), "")
112112
}
113113
modload.UpdateWorkFile(workFile)
114114
modload.WriteWorkFile(gowork, workFile)

src/cmd/go/testdata/script/work.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ go list -mod=readonly all
3434
stderr '^go: -mod may only be set to readonly when in workspace mode'
3535
go list -mod=mod -workfile=off all
3636

37-
# Test that duplicates in the directory list return an error
37+
# Test that duplicates in the use list return an error
3838
cp go.work go.work.backup
3939
cp go.work.dup go.work
4040
! go run example.com/b
@@ -59,22 +59,22 @@ go build -n -o foo foo.go
5959
-- go.work.dup --
6060
go 1.18
6161

62-
directory (
62+
use (
6363
a
6464
b
6565
../src/a
6666
)
6767
-- go.work.want --
6868
go 1.18
6969

70-
directory (
70+
use (
7171
./a
7272
./b
7373
)
7474
-- go.work.d --
7575
go 1.18
7676

77-
directory (
77+
use (
7878
a
7979
b
8080
d
@@ -133,7 +133,7 @@ func main() {
133133
-- go.work.backwards --
134134
go 1.18
135135

136-
directory (
136+
use (
137137
d
138138
b
139139
a

0 commit comments

Comments
 (0)