mirror of
https://github.com/mjl-/mox.git
synced 2024-12-27 08:53:48 +03:00
update to golang.org/x/mod@latest
This commit is contained in:
parent
e7e023c6d0
commit
09b13ed4d5
7 changed files with 239 additions and 18 deletions
2
go.mod
2
go.mod
|
@ -29,7 +29,7 @@ require (
|
||||||
github.com/prometheus/client_model v0.5.0 // indirect
|
github.com/prometheus/client_model v0.5.0 // indirect
|
||||||
github.com/prometheus/common v0.45.0 // indirect
|
github.com/prometheus/common v0.45.0 // indirect
|
||||||
github.com/prometheus/procfs v0.12.0 // indirect
|
github.com/prometheus/procfs v0.12.0 // indirect
|
||||||
golang.org/x/mod v0.17.0 // indirect
|
golang.org/x/mod v0.20.0 // indirect
|
||||||
golang.org/x/sync v0.7.0 // indirect
|
golang.org/x/sync v0.7.0 // indirect
|
||||||
golang.org/x/sys v0.24.0 // indirect
|
golang.org/x/sys v0.24.0 // indirect
|
||||||
golang.org/x/tools v0.20.0 // indirect
|
golang.org/x/tools v0.20.0 // indirect
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -78,8 +78,8 @@ golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+
|
||||||
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f h1:99ci1mjWVBWwJiEKYY6jWa4d2nTQVIEhZIptnrVb1XY=
|
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f h1:99ci1mjWVBWwJiEKYY6jWa4d2nTQVIEhZIptnrVb1XY=
|
||||||
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI=
|
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI=
|
||||||
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
|
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
|
||||||
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
|
golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
|
||||||
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
|
4
vendor/golang.org/x/mod/LICENSE
generated
vendored
4
vendor/golang.org/x/mod/LICENSE
generated
vendored
|
@ -1,4 +1,4 @@
|
||||||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
Copyright 2009 The Go Authors.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are
|
modification, are permitted provided that the following conditions are
|
||||||
|
@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer.
|
||||||
copyright notice, this list of conditions and the following disclaimer
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
in the documentation and/or other materials provided with the
|
in the documentation and/or other materials provided with the
|
||||||
distribution.
|
distribution.
|
||||||
* Neither the name of Google Inc. nor the names of its
|
* Neither the name of Google LLC nor the names of its
|
||||||
contributors may be used to endorse or promote products derived from
|
contributors may be used to endorse or promote products derived from
|
||||||
this software without specific prior written permission.
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
|
7
vendor/golang.org/x/mod/modfile/read.go
generated
vendored
7
vendor/golang.org/x/mod/modfile/read.go
generated
vendored
|
@ -226,8 +226,9 @@ func (x *FileSyntax) Cleanup() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if ww == 1 && len(stmt.RParen.Comments.Before) == 0 {
|
if ww == 1 && len(stmt.RParen.Comments.Before) == 0 {
|
||||||
// Collapse block into single line.
|
// Collapse block into single line but keep the Line reference used by the
|
||||||
line := &Line{
|
// parsed File structure.
|
||||||
|
*stmt.Line[0] = Line{
|
||||||
Comments: Comments{
|
Comments: Comments{
|
||||||
Before: commentsAdd(stmt.Before, stmt.Line[0].Before),
|
Before: commentsAdd(stmt.Before, stmt.Line[0].Before),
|
||||||
Suffix: commentsAdd(stmt.Line[0].Suffix, stmt.Suffix),
|
Suffix: commentsAdd(stmt.Line[0].Suffix, stmt.Suffix),
|
||||||
|
@ -235,7 +236,7 @@ func (x *FileSyntax) Cleanup() {
|
||||||
},
|
},
|
||||||
Token: stringsAdd(stmt.Token, stmt.Line[0].Token),
|
Token: stringsAdd(stmt.Token, stmt.Line[0].Token),
|
||||||
}
|
}
|
||||||
x.Stmt[w] = line
|
x.Stmt[w] = stmt.Line[0]
|
||||||
w++
|
w++
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
184
vendor/golang.org/x/mod/modfile/rule.go
generated
vendored
184
vendor/golang.org/x/mod/modfile/rule.go
generated
vendored
|
@ -38,10 +38,12 @@ type File struct {
|
||||||
Module *Module
|
Module *Module
|
||||||
Go *Go
|
Go *Go
|
||||||
Toolchain *Toolchain
|
Toolchain *Toolchain
|
||||||
|
Godebug []*Godebug
|
||||||
Require []*Require
|
Require []*Require
|
||||||
Exclude []*Exclude
|
Exclude []*Exclude
|
||||||
Replace []*Replace
|
Replace []*Replace
|
||||||
Retract []*Retract
|
Retract []*Retract
|
||||||
|
Tool []*Tool
|
||||||
|
|
||||||
Syntax *FileSyntax
|
Syntax *FileSyntax
|
||||||
}
|
}
|
||||||
|
@ -65,6 +67,13 @@ type Toolchain struct {
|
||||||
Syntax *Line
|
Syntax *Line
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A Godebug is a single godebug key=value statement.
|
||||||
|
type Godebug struct {
|
||||||
|
Key string
|
||||||
|
Value string
|
||||||
|
Syntax *Line
|
||||||
|
}
|
||||||
|
|
||||||
// An Exclude is a single exclude statement.
|
// An Exclude is a single exclude statement.
|
||||||
type Exclude struct {
|
type Exclude struct {
|
||||||
Mod module.Version
|
Mod module.Version
|
||||||
|
@ -85,6 +94,12 @@ type Retract struct {
|
||||||
Syntax *Line
|
Syntax *Line
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A Tool is a single tool statement.
|
||||||
|
type Tool struct {
|
||||||
|
Path string
|
||||||
|
Syntax *Line
|
||||||
|
}
|
||||||
|
|
||||||
// A VersionInterval represents a range of versions with upper and lower bounds.
|
// A VersionInterval represents a range of versions with upper and lower bounds.
|
||||||
// Intervals are closed: both bounds are included. When Low is equal to High,
|
// Intervals are closed: both bounds are included. When Low is equal to High,
|
||||||
// the interval may refer to a single version ('v1.2.3') or an interval
|
// the interval may refer to a single version ('v1.2.3') or an interval
|
||||||
|
@ -289,7 +304,7 @@ func parseToFile(file string, data []byte, fix VersionFixer, strict bool) (parse
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
case "module", "require", "exclude", "replace", "retract":
|
case "module", "godebug", "require", "exclude", "replace", "retract", "tool":
|
||||||
for _, l := range x.Line {
|
for _, l := range x.Line {
|
||||||
f.add(&errs, x, l, x.Token[0], l.Token, fix, strict)
|
f.add(&errs, x, l, x.Token[0], l.Token, fix, strict)
|
||||||
}
|
}
|
||||||
|
@ -308,7 +323,9 @@ var laxGoVersionRE = lazyregexp.New(`^v?(([1-9][0-9]*)\.(0|[1-9][0-9]*))([^0-9].
|
||||||
|
|
||||||
// Toolchains must be named beginning with `go1`,
|
// Toolchains must be named beginning with `go1`,
|
||||||
// like "go1.20.3" or "go1.20.3-gccgo". As a special case, "default" is also permitted.
|
// like "go1.20.3" or "go1.20.3-gccgo". As a special case, "default" is also permitted.
|
||||||
// TODO(samthanawalla): Replace regex with https://pkg.go.dev/go/version#IsValid in 1.23+
|
// Note that this regexp is a much looser condition than go/version.IsValid,
|
||||||
|
// for forward compatibility.
|
||||||
|
// (This code has to be work to identify new toolchains even if we tweak the syntax in the future.)
|
||||||
var ToolchainRE = lazyregexp.New(`^default$|^go1($|\.)`)
|
var ToolchainRE = lazyregexp.New(`^default$|^go1($|\.)`)
|
||||||
|
|
||||||
func (f *File) add(errs *ErrorList, block *LineBlock, line *Line, verb string, args []string, fix VersionFixer, strict bool) {
|
func (f *File) add(errs *ErrorList, block *LineBlock, line *Line, verb string, args []string, fix VersionFixer, strict bool) {
|
||||||
|
@ -384,7 +401,7 @@ func (f *File) add(errs *ErrorList, block *LineBlock, line *Line, verb string, a
|
||||||
if len(args) != 1 {
|
if len(args) != 1 {
|
||||||
errorf("toolchain directive expects exactly one argument")
|
errorf("toolchain directive expects exactly one argument")
|
||||||
return
|
return
|
||||||
} else if strict && !ToolchainRE.MatchString(args[0]) {
|
} else if !ToolchainRE.MatchString(args[0]) {
|
||||||
errorf("invalid toolchain version '%s': must match format go1.23.0 or default", args[0])
|
errorf("invalid toolchain version '%s': must match format go1.23.0 or default", args[0])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -412,6 +429,22 @@ func (f *File) add(errs *ErrorList, block *LineBlock, line *Line, verb string, a
|
||||||
}
|
}
|
||||||
f.Module.Mod = module.Version{Path: s}
|
f.Module.Mod = module.Version{Path: s}
|
||||||
|
|
||||||
|
case "godebug":
|
||||||
|
if len(args) != 1 || strings.ContainsAny(args[0], "\"`',") {
|
||||||
|
errorf("usage: godebug key=value")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
key, value, ok := strings.Cut(args[0], "=")
|
||||||
|
if !ok {
|
||||||
|
errorf("usage: godebug key=value")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
f.Godebug = append(f.Godebug, &Godebug{
|
||||||
|
Key: key,
|
||||||
|
Value: value,
|
||||||
|
Syntax: line,
|
||||||
|
})
|
||||||
|
|
||||||
case "require", "exclude":
|
case "require", "exclude":
|
||||||
if len(args) != 2 {
|
if len(args) != 2 {
|
||||||
errorf("usage: %s module/path v1.2.3", verb)
|
errorf("usage: %s module/path v1.2.3", verb)
|
||||||
|
@ -483,6 +516,21 @@ func (f *File) add(errs *ErrorList, block *LineBlock, line *Line, verb string, a
|
||||||
Syntax: line,
|
Syntax: line,
|
||||||
}
|
}
|
||||||
f.Retract = append(f.Retract, retract)
|
f.Retract = append(f.Retract, retract)
|
||||||
|
|
||||||
|
case "tool":
|
||||||
|
if len(args) != 1 {
|
||||||
|
errorf("tool directive expects exactly one argument")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
s, err := parseString(&args[0])
|
||||||
|
if err != nil {
|
||||||
|
errorf("invalid quoted string: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
f.Tool = append(f.Tool, &Tool{
|
||||||
|
Path: s,
|
||||||
|
Syntax: line,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -654,6 +702,22 @@ func (f *WorkFile) add(errs *ErrorList, line *Line, verb string, args []string,
|
||||||
f.Toolchain = &Toolchain{Syntax: line}
|
f.Toolchain = &Toolchain{Syntax: line}
|
||||||
f.Toolchain.Name = args[0]
|
f.Toolchain.Name = args[0]
|
||||||
|
|
||||||
|
case "godebug":
|
||||||
|
if len(args) != 1 || strings.ContainsAny(args[0], "\"`',") {
|
||||||
|
errorf("usage: godebug key=value")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
key, value, ok := strings.Cut(args[0], "=")
|
||||||
|
if !ok {
|
||||||
|
errorf("usage: godebug key=value")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
f.Godebug = append(f.Godebug, &Godebug{
|
||||||
|
Key: key,
|
||||||
|
Value: value,
|
||||||
|
Syntax: line,
|
||||||
|
})
|
||||||
|
|
||||||
case "use":
|
case "use":
|
||||||
if len(args) != 1 {
|
if len(args) != 1 {
|
||||||
errorf("usage: %s local/dir", verb)
|
errorf("usage: %s local/dir", verb)
|
||||||
|
@ -929,6 +993,15 @@ func (f *File) Format() ([]byte, error) {
|
||||||
// Cleanup cleans out all the cleared entries.
|
// Cleanup cleans out all the cleared entries.
|
||||||
func (f *File) Cleanup() {
|
func (f *File) Cleanup() {
|
||||||
w := 0
|
w := 0
|
||||||
|
for _, g := range f.Godebug {
|
||||||
|
if g.Key != "" {
|
||||||
|
f.Godebug[w] = g
|
||||||
|
w++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f.Godebug = f.Godebug[:w]
|
||||||
|
|
||||||
|
w = 0
|
||||||
for _, r := range f.Require {
|
for _, r := range f.Require {
|
||||||
if r.Mod.Path != "" {
|
if r.Mod.Path != "" {
|
||||||
f.Require[w] = r
|
f.Require[w] = r
|
||||||
|
@ -1027,6 +1100,45 @@ func (f *File) AddToolchainStmt(name string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddGodebug sets the first godebug line for key to value,
|
||||||
|
// preserving any existing comments for that line and removing all
|
||||||
|
// other godebug lines for key.
|
||||||
|
//
|
||||||
|
// If no line currently exists for key, AddGodebug adds a new line
|
||||||
|
// at the end of the last godebug block.
|
||||||
|
func (f *File) AddGodebug(key, value string) error {
|
||||||
|
need := true
|
||||||
|
for _, g := range f.Godebug {
|
||||||
|
if g.Key == key {
|
||||||
|
if need {
|
||||||
|
g.Value = value
|
||||||
|
f.Syntax.updateLine(g.Syntax, "godebug", key+"="+value)
|
||||||
|
need = false
|
||||||
|
} else {
|
||||||
|
g.Syntax.markRemoved()
|
||||||
|
*g = Godebug{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if need {
|
||||||
|
f.addNewGodebug(key, value)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// addNewGodebug adds a new godebug key=value line at the end
|
||||||
|
// of the last godebug block, regardless of any existing godebug lines for key.
|
||||||
|
func (f *File) addNewGodebug(key, value string) {
|
||||||
|
line := f.Syntax.addLine(nil, "godebug", key+"="+value)
|
||||||
|
g := &Godebug{
|
||||||
|
Key: key,
|
||||||
|
Value: value,
|
||||||
|
Syntax: line,
|
||||||
|
}
|
||||||
|
f.Godebug = append(f.Godebug, g)
|
||||||
|
}
|
||||||
|
|
||||||
// AddRequire sets the first require line for path to version vers,
|
// AddRequire sets the first require line for path to version vers,
|
||||||
// preserving any existing comments for that line and removing all
|
// preserving any existing comments for that line and removing all
|
||||||
// other lines for path.
|
// other lines for path.
|
||||||
|
@ -1334,6 +1446,16 @@ func (f *File) SetRequireSeparateIndirect(req []*Require) {
|
||||||
f.SortBlocks()
|
f.SortBlocks()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *File) DropGodebug(key string) error {
|
||||||
|
for _, g := range f.Godebug {
|
||||||
|
if g.Key == key {
|
||||||
|
g.Syntax.markRemoved()
|
||||||
|
*g = Godebug{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (f *File) DropRequire(path string) error {
|
func (f *File) DropRequire(path string) error {
|
||||||
for _, r := range f.Require {
|
for _, r := range f.Require {
|
||||||
if r.Mod.Path == path {
|
if r.Mod.Path == path {
|
||||||
|
@ -1467,6 +1589,36 @@ func (f *File) DropRetract(vi VersionInterval) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddTool adds a new tool directive with the given path.
|
||||||
|
// It does nothing if the tool line already exists.
|
||||||
|
func (f *File) AddTool(path string) error {
|
||||||
|
for _, t := range f.Tool {
|
||||||
|
if t.Path == path {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
f.Tool = append(f.Tool, &Tool{
|
||||||
|
Path: path,
|
||||||
|
Syntax: f.Syntax.addLine(nil, "tool", path),
|
||||||
|
})
|
||||||
|
|
||||||
|
f.SortBlocks()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveTool removes a tool directive with the given path.
|
||||||
|
// It does nothing if no such tool directive exists.
|
||||||
|
func (f *File) DropTool(path string) error {
|
||||||
|
for _, t := range f.Tool {
|
||||||
|
if t.Path == path {
|
||||||
|
t.Syntax.markRemoved()
|
||||||
|
*t = Tool{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (f *File) SortBlocks() {
|
func (f *File) SortBlocks() {
|
||||||
f.removeDups() // otherwise sorting is unsafe
|
f.removeDups() // otherwise sorting is unsafe
|
||||||
|
|
||||||
|
@ -1493,9 +1645,9 @@ func (f *File) SortBlocks() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// removeDups removes duplicate exclude and replace directives.
|
// removeDups removes duplicate exclude, replace and tool directives.
|
||||||
//
|
//
|
||||||
// Earlier exclude directives take priority.
|
// Earlier exclude and tool directives take priority.
|
||||||
//
|
//
|
||||||
// Later replace directives take priority.
|
// Later replace directives take priority.
|
||||||
//
|
//
|
||||||
|
@ -1505,10 +1657,10 @@ func (f *File) SortBlocks() {
|
||||||
// retract directives are not de-duplicated since comments are
|
// retract directives are not de-duplicated since comments are
|
||||||
// meaningful, and versions may be retracted multiple times.
|
// meaningful, and versions may be retracted multiple times.
|
||||||
func (f *File) removeDups() {
|
func (f *File) removeDups() {
|
||||||
removeDups(f.Syntax, &f.Exclude, &f.Replace)
|
removeDups(f.Syntax, &f.Exclude, &f.Replace, &f.Tool)
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeDups(syntax *FileSyntax, exclude *[]*Exclude, replace *[]*Replace) {
|
func removeDups(syntax *FileSyntax, exclude *[]*Exclude, replace *[]*Replace, tool *[]*Tool) {
|
||||||
kill := make(map[*Line]bool)
|
kill := make(map[*Line]bool)
|
||||||
|
|
||||||
// Remove duplicate excludes.
|
// Remove duplicate excludes.
|
||||||
|
@ -1549,6 +1701,24 @@ func removeDups(syntax *FileSyntax, exclude *[]*Exclude, replace *[]*Replace) {
|
||||||
}
|
}
|
||||||
*replace = repl
|
*replace = repl
|
||||||
|
|
||||||
|
if tool != nil {
|
||||||
|
haveTool := make(map[string]bool)
|
||||||
|
for _, t := range *tool {
|
||||||
|
if haveTool[t.Path] {
|
||||||
|
kill[t.Syntax] = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
haveTool[t.Path] = true
|
||||||
|
}
|
||||||
|
var newTool []*Tool
|
||||||
|
for _, t := range *tool {
|
||||||
|
if !kill[t.Syntax] {
|
||||||
|
newTool = append(newTool, t)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*tool = newTool
|
||||||
|
}
|
||||||
|
|
||||||
// Duplicate require and retract directives are not removed.
|
// Duplicate require and retract directives are not removed.
|
||||||
|
|
||||||
// Drop killed statements from the syntax tree.
|
// Drop killed statements from the syntax tree.
|
||||||
|
|
54
vendor/golang.org/x/mod/modfile/work.go
generated
vendored
54
vendor/golang.org/x/mod/modfile/work.go
generated
vendored
|
@ -14,6 +14,7 @@ import (
|
||||||
type WorkFile struct {
|
type WorkFile struct {
|
||||||
Go *Go
|
Go *Go
|
||||||
Toolchain *Toolchain
|
Toolchain *Toolchain
|
||||||
|
Godebug []*Godebug
|
||||||
Use []*Use
|
Use []*Use
|
||||||
Replace []*Replace
|
Replace []*Replace
|
||||||
|
|
||||||
|
@ -68,7 +69,7 @@ func ParseWork(file string, data []byte, fix VersionFixer) (*WorkFile, error) {
|
||||||
Err: fmt.Errorf("unknown block type: %s", strings.Join(x.Token, " ")),
|
Err: fmt.Errorf("unknown block type: %s", strings.Join(x.Token, " ")),
|
||||||
})
|
})
|
||||||
continue
|
continue
|
||||||
case "use", "replace":
|
case "godebug", "use", "replace":
|
||||||
for _, l := range x.Line {
|
for _, l := range x.Line {
|
||||||
f.add(&errs, l, x.Token[0], l.Token, fix)
|
f.add(&errs, l, x.Token[0], l.Token, fix)
|
||||||
}
|
}
|
||||||
|
@ -184,6 +185,55 @@ func (f *WorkFile) DropToolchainStmt() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddGodebug sets the first godebug line for key to value,
|
||||||
|
// preserving any existing comments for that line and removing all
|
||||||
|
// other godebug lines for key.
|
||||||
|
//
|
||||||
|
// If no line currently exists for key, AddGodebug adds a new line
|
||||||
|
// at the end of the last godebug block.
|
||||||
|
func (f *WorkFile) AddGodebug(key, value string) error {
|
||||||
|
need := true
|
||||||
|
for _, g := range f.Godebug {
|
||||||
|
if g.Key == key {
|
||||||
|
if need {
|
||||||
|
g.Value = value
|
||||||
|
f.Syntax.updateLine(g.Syntax, "godebug", key+"="+value)
|
||||||
|
need = false
|
||||||
|
} else {
|
||||||
|
g.Syntax.markRemoved()
|
||||||
|
*g = Godebug{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if need {
|
||||||
|
f.addNewGodebug(key, value)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// addNewGodebug adds a new godebug key=value line at the end
|
||||||
|
// of the last godebug block, regardless of any existing godebug lines for key.
|
||||||
|
func (f *WorkFile) addNewGodebug(key, value string) {
|
||||||
|
line := f.Syntax.addLine(nil, "godebug", key+"="+value)
|
||||||
|
g := &Godebug{
|
||||||
|
Key: key,
|
||||||
|
Value: value,
|
||||||
|
Syntax: line,
|
||||||
|
}
|
||||||
|
f.Godebug = append(f.Godebug, g)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *WorkFile) DropGodebug(key string) error {
|
||||||
|
for _, g := range f.Godebug {
|
||||||
|
if g.Key == key {
|
||||||
|
g.Syntax.markRemoved()
|
||||||
|
*g = Godebug{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (f *WorkFile) AddUse(diskPath, modulePath string) error {
|
func (f *WorkFile) AddUse(diskPath, modulePath string) error {
|
||||||
need := true
|
need := true
|
||||||
for _, d := range f.Use {
|
for _, d := range f.Use {
|
||||||
|
@ -281,5 +331,5 @@ func (f *WorkFile) SortBlocks() {
|
||||||
// retract directives are not de-duplicated since comments are
|
// retract directives are not de-duplicated since comments are
|
||||||
// meaningful, and versions may be retracted multiple times.
|
// meaningful, and versions may be retracted multiple times.
|
||||||
func (f *WorkFile) removeDups() {
|
func (f *WorkFile) removeDups() {
|
||||||
removeDups(f.Syntax, nil, &f.Replace)
|
removeDups(f.Syntax, nil, &f.Replace, nil)
|
||||||
}
|
}
|
||||||
|
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
|
@ -74,7 +74,7 @@ golang.org/x/crypto/pbkdf2
|
||||||
# golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f
|
# golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f
|
||||||
## explicit; go 1.20
|
## explicit; go 1.20
|
||||||
golang.org/x/exp/maps
|
golang.org/x/exp/maps
|
||||||
# golang.org/x/mod v0.17.0
|
# golang.org/x/mod v0.20.0
|
||||||
## explicit; go 1.18
|
## explicit; go 1.18
|
||||||
golang.org/x/mod/internal/lazyregexp
|
golang.org/x/mod/internal/lazyregexp
|
||||||
golang.org/x/mod/modfile
|
golang.org/x/mod/modfile
|
||||||
|
|
Loading…
Reference in a new issue