diff options
author | Ian Lance Taylor <iant@golang.org> | 2021-01-27 17:55:50 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2021-01-29 11:04:55 -0800 |
commit | 726b7aa004d6885388a76521222602b8552a41ee (patch) | |
tree | 5179037ef840a43dcea0f3be4e07dbcbcfcb2c4a /libgo/go/golang.org | |
parent | 91a95ad2ae0e0f2fa953fafe55ff2ec32c8277d5 (diff) | |
download | gcc-726b7aa004d6885388a76521222602b8552a41ee.zip gcc-726b7aa004d6885388a76521222602b8552a41ee.tar.gz gcc-726b7aa004d6885388a76521222602b8552a41ee.tar.bz2 |
libgo: update to Go1.16rc1
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/287493
Diffstat (limited to 'libgo/go/golang.org')
12 files changed, 108 insertions, 56 deletions
diff --git a/libgo/go/golang.org/x/mod/modfile/rule.go b/libgo/go/golang.org/x/mod/modfile/rule.go index 83398dd..c6a189d 100644 --- a/libgo/go/golang.org/x/mod/modfile/rule.go +++ b/libgo/go/golang.org/x/mod/modfile/rule.go @@ -832,7 +832,16 @@ func (f *File) DropRequire(path string) error { return nil } +// AddExclude adds a exclude statement to the mod file. Errors if the provided +// version is not a canonical version string func (f *File) AddExclude(path, vers string) error { + if !isCanonicalVersion(vers) { + return &module.InvalidVersionError{ + Version: vers, + Err: errors.New("must be of the form v1.2.3"), + } + } + var hint *Line for _, x := range f.Exclude { if x.Mod.Path == path && x.Mod.Version == vers { @@ -904,7 +913,22 @@ func (f *File) DropReplace(oldPath, oldVers string) error { return nil } +// AddRetract adds a retract statement to the mod file. Errors if the provided +// version interval does not consist of canonical version strings func (f *File) AddRetract(vi VersionInterval, rationale string) error { + if !isCanonicalVersion(vi.High) { + return &module.InvalidVersionError{ + Version: vi.High, + Err: errors.New("must be of the form v1.2.3"), + } + } + if !isCanonicalVersion(vi.Low) { + return &module.InvalidVersionError{ + Version: vi.Low, + Err: errors.New("must be of the form v1.2.3"), + } + } + r := &Retract{ VersionInterval: vi, } @@ -1061,3 +1085,9 @@ func lineRetractLess(li, lj *Line) bool { } return semver.Compare(vii.High, vij.High) > 0 } + +// isCanonicalVersion tests if the provided version string represents a valid +// canonical version. +func isCanonicalVersion(vers string) bool { + return vers != "" && semver.Canonical(vers) == vers +} diff --git a/libgo/go/golang.org/x/tools/go/analysis/analysis.go b/libgo/go/golang.org/x/tools/go/analysis/analysis.go index 8c3c2e7..d11505a 100644 --- a/libgo/go/golang.org/x/tools/go/analysis/analysis.go +++ b/libgo/go/golang.org/x/tools/go/analysis/analysis.go @@ -1,3 +1,7 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package analysis import ( diff --git a/libgo/go/golang.org/x/tools/go/analysis/diagnostic.go b/libgo/go/golang.org/x/tools/go/analysis/diagnostic.go index 57eaf6f..cd462a0 100644 --- a/libgo/go/golang.org/x/tools/go/analysis/diagnostic.go +++ b/libgo/go/golang.org/x/tools/go/analysis/diagnostic.go @@ -1,3 +1,7 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package analysis import "go/token" diff --git a/libgo/go/golang.org/x/tools/go/analysis/doc.go b/libgo/go/golang.org/x/tools/go/analysis/doc.go index 9fa3302..94a3bd5 100644 --- a/libgo/go/golang.org/x/tools/go/analysis/doc.go +++ b/libgo/go/golang.org/x/tools/go/analysis/doc.go @@ -1,3 +1,7 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + /* Package analysis defines the interface between a modular static diff --git a/libgo/go/golang.org/x/tools/go/analysis/internal/analysisflags/help.go b/libgo/go/golang.org/x/tools/go/analysis/internal/analysisflags/help.go index c5a70f3..ce92892 100644 --- a/libgo/go/golang.org/x/tools/go/analysis/internal/analysisflags/help.go +++ b/libgo/go/golang.org/x/tools/go/analysis/internal/analysisflags/help.go @@ -1,3 +1,7 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package analysisflags import ( diff --git a/libgo/go/golang.org/x/tools/go/analysis/passes/internal/analysisutil/util.go b/libgo/go/golang.org/x/tools/go/analysis/passes/internal/analysisutil/util.go index 80c9476..ac37e47 100644 --- a/libgo/go/golang.org/x/tools/go/analysis/passes/internal/analysisutil/util.go +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/internal/analysisutil/util.go @@ -1,3 +1,7 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + // Package analysisutil defines various helper functions // used by two or more packages beneath go/analysis. package analysisutil diff --git a/libgo/go/golang.org/x/tools/go/analysis/passes/printf/types.go b/libgo/go/golang.org/x/tools/go/analysis/passes/printf/types.go index bd8a594..6a5fae4 100644 --- a/libgo/go/golang.org/x/tools/go/analysis/passes/printf/types.go +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/printf/types.go @@ -1,3 +1,7 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package printf import ( diff --git a/libgo/go/golang.org/x/tools/go/analysis/passes/structtag/structtag.go b/libgo/go/golang.org/x/tools/go/analysis/passes/structtag/structtag.go index 0255564..f0b1505 100644 --- a/libgo/go/golang.org/x/tools/go/analysis/passes/structtag/structtag.go +++ b/libgo/go/golang.org/x/tools/go/analysis/passes/structtag/structtag.go @@ -207,12 +207,12 @@ var ( ) // validateStructTag parses the struct tag and returns an error if it is not -// in the canonical format, as defined by reflect.StructTag. +// in the canonical format, which is a space-separated list of key:"value" +// settings. The value may contain spaces. func validateStructTag(tag string) error { // This code is based on the StructTag.Get code in package reflect. n := 0 - var keys []string for ; tag != ""; n++ { if n > 0 && tag != "" && tag[0] != ' ' { // More restrictive than reflect, but catches likely mistakes @@ -240,27 +240,14 @@ func validateStructTag(tag string) error { if i == 0 { return errTagKeySyntax } - if i+1 >= len(tag) || tag[i] < ' ' || tag[i] == 0x7f { + if i+1 >= len(tag) || tag[i] != ':' { return errTagSyntax } - key := tag[:i] - keys = append(keys, key) - tag = tag[i:] - - // If we found a space char here - assume that we have a tag with - // multiple keys. - if tag[0] == ' ' { - continue - } - - // Spaces were filtered above so we assume that here we have - // only valid tag value started with `:"`. - if tag[0] != ':' || tag[1] != '"' { + if tag[i+1] != '"' { return errTagValueSyntax } - - // Remove the colon leaving tag at the start of the quoted string. - tag = tag[1:] + key := tag[:i] + tag = tag[i+1:] // Scan quoted string to find value. i = 1 @@ -276,56 +263,51 @@ func validateStructTag(tag string) error { qvalue := tag[:i+1] tag = tag[i+1:] - wholeValue, err := strconv.Unquote(qvalue) + value, err := strconv.Unquote(qvalue) if err != nil { return errTagValueSyntax } - for _, key := range keys { - if !checkTagSpaces[key] { - continue - } - - value := wholeValue - switch key { - case "xml": - // If the first or last character in the XML tag is a space, it is - // suspicious. - if strings.Trim(value, " ") != value { - return errTagValueSpace - } + if !checkTagSpaces[key] { + continue + } - // If there are multiple spaces, they are suspicious. - if strings.Count(value, " ") > 1 { - return errTagValueSpace - } + switch key { + case "xml": + // If the first or last character in the XML tag is a space, it is + // suspicious. + if strings.Trim(value, " ") != value { + return errTagValueSpace + } - // If there is no comma, skip the rest of the checks. - comma := strings.IndexRune(value, ',') - if comma < 0 { - continue - } + // If there are multiple spaces, they are suspicious. + if strings.Count(value, " ") > 1 { + return errTagValueSpace + } - // If the character before a comma is a space, this is suspicious. - if comma > 0 && value[comma-1] == ' ' { - return errTagValueSpace - } - value = value[comma+1:] - case "json": - // JSON allows using spaces in the name, so skip it. - comma := strings.IndexRune(value, ',') - if comma < 0 { - continue - } - value = value[comma+1:] + // If there is no comma, skip the rest of the checks. + comma := strings.IndexRune(value, ',') + if comma < 0 { + continue } - if strings.IndexByte(value, ' ') >= 0 { + // If the character before a comma is a space, this is suspicious. + if comma > 0 && value[comma-1] == ' ' { return errTagValueSpace } + value = value[comma+1:] + case "json": + // JSON allows using spaces in the name, so skip it. + comma := strings.IndexRune(value, ',') + if comma < 0 { + continue + } + value = value[comma+1:] } - keys = keys[:0] + if strings.IndexByte(value, ' ') >= 0 { + return errTagValueSpace + } } return nil } diff --git a/libgo/go/golang.org/x/tools/go/analysis/unitchecker/unitchecker112.go b/libgo/go/golang.org/x/tools/go/analysis/unitchecker/unitchecker112.go index 683b7e9..9051456 100644 --- a/libgo/go/golang.org/x/tools/go/analysis/unitchecker/unitchecker112.go +++ b/libgo/go/golang.org/x/tools/go/analysis/unitchecker/unitchecker112.go @@ -1,3 +1,7 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + // +build go1.12 package unitchecker diff --git a/libgo/go/golang.org/x/tools/go/analysis/validate.go b/libgo/go/golang.org/x/tools/go/analysis/validate.go index ad0e727..23e57bf 100644 --- a/libgo/go/golang.org/x/tools/go/analysis/validate.go +++ b/libgo/go/golang.org/x/tools/go/analysis/validate.go @@ -1,3 +1,7 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package analysis import ( diff --git a/libgo/go/golang.org/x/tools/go/ast/astutil/util.go b/libgo/go/golang.org/x/tools/go/ast/astutil/util.go index 7630629..919d530 100644 --- a/libgo/go/golang.org/x/tools/go/ast/astutil/util.go +++ b/libgo/go/golang.org/x/tools/go/ast/astutil/util.go @@ -1,3 +1,7 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package astutil import "go/ast" diff --git a/libgo/go/golang.org/x/tools/go/ast/inspector/typeof.go b/libgo/go/golang.org/x/tools/go/ast/inspector/typeof.go index d61301b..b6b00cf 100644 --- a/libgo/go/golang.org/x/tools/go/ast/inspector/typeof.go +++ b/libgo/go/golang.org/x/tools/go/ast/inspector/typeof.go @@ -1,3 +1,7 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package inspector // This file defines func typeOf(ast.Node) uint64. |