Fix #387: update goimports
$ git cherry --abbrev -v d66bd3c5d5a6 379209517ffe | fgrep imports: + a06a922a imports: update zstdlib to Go 1.12 + cb89afad imports: drop anything after a non identifier rune in package names
This commit is contained in:
parent
9916a2fb79
commit
81cf48771e
2
go.mod
2
go.mod
@ -55,7 +55,7 @@ require (
|
||||
github.com/spf13/viper v1.0.2
|
||||
github.com/stretchr/testify v1.2.1
|
||||
golang.org/x/crypto v0.0.0-20180505025534-4ec37c66abab // indirect
|
||||
golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6
|
||||
golang.org/x/tools v0.0.0-20190125232054-379209517ffe
|
||||
gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect
|
||||
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect
|
||||
gopkg.in/yaml.v2 v2.2.1
|
||||
|
4
go.sum
4
go.sum
@ -153,8 +153,8 @@ golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGm
|
||||
golang.org/x/tools v0.0.0-20181117154741-2ddaf7f79a09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20181205014116-22934f0fdb62/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190121143147-24cd39ecf745/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6 h1:iZgcI2DDp6zW5v9Z/5+f0NuqoxNdmzg4hivjk2WLXpY=
|
||||
golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190125232054-379209517ffe h1:ZJ3JgA0fnPnX6nSjHp3y5XWNUf3zaTbWlilINJoPFkQ=
|
||||
golang.org/x/tools v0.0.0-20190125232054-379209517ffe/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
gopkg.in/airbrake/gobrake.v2 v2.0.9 h1:7z2uVWwn7oVeeugY1DtlPAy5H+KYgB1KeKTnqjNatLo=
|
||||
gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
|
4
vendor/golang.org/x/tools/go/internal/gcimporter/bexport.go
generated
vendored
4
vendor/golang.org/x/tools/go/internal/gcimporter/bexport.go
generated
vendored
@ -127,10 +127,10 @@ func BExportData(fset *token.FileSet, pkg *types.Package) (b []byte, err error)
|
||||
// --- generic export data ---
|
||||
|
||||
// populate type map with predeclared "known" types
|
||||
for index, typ := range predeclared {
|
||||
for index, typ := range predeclared() {
|
||||
p.typIndex[typ] = index
|
||||
}
|
||||
if len(p.typIndex) != len(predeclared) {
|
||||
if len(p.typIndex) != len(predeclared()) {
|
||||
return nil, internalError("duplicate entries in type map?")
|
||||
}
|
||||
|
||||
|
14
vendor/golang.org/x/tools/go/internal/gcimporter/bimport.go
generated
vendored
14
vendor/golang.org/x/tools/go/internal/gcimporter/bimport.go
generated
vendored
@ -126,7 +126,7 @@ func BImportData(fset *token.FileSet, imports map[string]*types.Package, data []
|
||||
// --- generic export data ---
|
||||
|
||||
// populate typList with predeclared "known" types
|
||||
p.typList = append(p.typList, predeclared...)
|
||||
p.typList = append(p.typList, predeclared()...)
|
||||
|
||||
// read package data
|
||||
pkg = p.pkg()
|
||||
@ -976,8 +976,13 @@ const (
|
||||
aliasTag
|
||||
)
|
||||
|
||||
var predeclared = []types.Type{
|
||||
// basic types
|
||||
var predecl []types.Type // initialized lazily
|
||||
|
||||
func predeclared() []types.Type {
|
||||
if predecl == nil {
|
||||
// initialize lazily to be sure that all
|
||||
// elements have been initialized before
|
||||
predecl = []types.Type{ // basic types
|
||||
types.Typ[types.Bool],
|
||||
types.Typ[types.Int],
|
||||
types.Typ[types.Int8],
|
||||
@ -1021,6 +1026,9 @@ var predeclared = []types.Type{
|
||||
// used internally by gc; never used by this package or in .a files
|
||||
anyType{},
|
||||
}
|
||||
}
|
||||
return predecl
|
||||
}
|
||||
|
||||
type anyType struct{}
|
||||
|
||||
|
14
vendor/golang.org/x/tools/go/internal/gcimporter/iimport.go
generated
vendored
14
vendor/golang.org/x/tools/go/internal/gcimporter/iimport.go
generated
vendored
@ -109,7 +109,7 @@ func IImportData(fset *token.FileSet, imports map[string]*types.Package, data []
|
||||
},
|
||||
}
|
||||
|
||||
for i, pt := range predeclared {
|
||||
for i, pt := range predeclared() {
|
||||
p.typCache[uint64(i)] = pt
|
||||
}
|
||||
|
||||
@ -142,8 +142,12 @@ func IImportData(fset *token.FileSet, imports map[string]*types.Package, data []
|
||||
p.pkgIndex[pkg] = nameIndex
|
||||
pkgList[i] = pkg
|
||||
}
|
||||
|
||||
localpkg := pkgList[0]
|
||||
var localpkg *types.Package
|
||||
for _, pkg := range pkgList {
|
||||
if pkg.Path() == path {
|
||||
localpkg = pkg
|
||||
}
|
||||
}
|
||||
|
||||
names := make([]string, 0, len(p.pkgIndex[localpkg]))
|
||||
for name := range p.pkgIndex[localpkg] {
|
||||
@ -330,6 +334,10 @@ func (r *importReader) value() (typ types.Type, val constant.Value) {
|
||||
val = constant.BinaryOp(re, token.ADD, constant.MakeImag(im))
|
||||
|
||||
default:
|
||||
if b.Kind() == types.Invalid {
|
||||
val = constant.MakeUnknown()
|
||||
return
|
||||
}
|
||||
errorf("unexpected type %v", typ) // panics
|
||||
panic("unreachable")
|
||||
}
|
||||
|
6
vendor/golang.org/x/tools/go/packages/doc.go
generated
vendored
6
vendor/golang.org/x/tools/go/packages/doc.go
generated
vendored
@ -14,7 +14,7 @@ but all patterns with the prefix "query=", where query is a
|
||||
non-empty string of letters from [a-z], are reserved and may be
|
||||
interpreted as query operators.
|
||||
|
||||
Three query operators are currently supported: "file", "pattern", and "name".
|
||||
Two query operators are currently supported: "file" and "pattern".
|
||||
|
||||
The query "file=path/to/file.go" matches the package or packages enclosing
|
||||
the Go source file path/to/file.go. For example "file=~/go/src/fmt/print.go"
|
||||
@ -25,10 +25,6 @@ the underlying build tool. In most cases this is unnecessary,
|
||||
but an application can use Load("pattern=" + x) as an escaping mechanism
|
||||
to ensure that x is not interpreted as a query operator if it contains '='.
|
||||
|
||||
The query "name=identifier" matches packages whose package declaration contains
|
||||
the specified identifier. For example, "name=rand" would match the packages
|
||||
"math/rand" and "crypto/rand", and "name=main" would match all executables.
|
||||
|
||||
All other query operators are reserved for future use and currently
|
||||
cause Load to report an error.
|
||||
|
||||
|
2
vendor/golang.org/x/tools/go/packages/golist.go
generated
vendored
2
vendor/golang.org/x/tools/go/packages/golist.go
generated
vendored
@ -104,7 +104,7 @@ extractQueries:
|
||||
containFiles = append(containFiles, value)
|
||||
case "pattern":
|
||||
restPatterns = append(restPatterns, value)
|
||||
case "name":
|
||||
case "iamashamedtousethedisabledqueryname":
|
||||
packagesNamed = append(packagesNamed, value)
|
||||
case "": // not a reserved query
|
||||
restPatterns = append(restPatterns, pattern)
|
||||
|
36
vendor/golang.org/x/tools/imports/fix.go
generated
vendored
36
vendor/golang.org/x/tools/imports/fix.go
generated
vendored
@ -23,6 +23,8 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
|
||||
"golang.org/x/tools/go/ast/astutil"
|
||||
"golang.org/x/tools/go/packages"
|
||||
@ -289,7 +291,7 @@ func (p *pass) importIdentifier(imp *importInfo) string {
|
||||
if known != nil && known.name != "" {
|
||||
return known.name
|
||||
}
|
||||
return importPathToNameBasic(imp.importPath, p.srcDir)
|
||||
return importPathToAssumedName(imp.importPath)
|
||||
}
|
||||
|
||||
// load reads in everything necessary to run a pass, and reports whether the
|
||||
@ -389,7 +391,7 @@ func (p *pass) fix() bool {
|
||||
}
|
||||
path := strings.Trim(imp.Path.Value, `""`)
|
||||
ident := p.importIdentifier(&importInfo{importPath: path})
|
||||
if ident != importPathToNameBasic(path, p.srcDir) {
|
||||
if ident != importPathToAssumedName(path) {
|
||||
imp.Name = &ast.Ident{Name: ident, NamePos: imp.Pos()}
|
||||
}
|
||||
}
|
||||
@ -648,7 +650,7 @@ func (r *goPackagesResolver) loadPackageNames(importPaths []string, srcDir strin
|
||||
if _, ok := names[path]; ok {
|
||||
continue
|
||||
}
|
||||
names[path] = importPathToNameBasic(path, srcDir)
|
||||
names[path] = importPathToAssumedName(path)
|
||||
}
|
||||
return names, nil
|
||||
|
||||
@ -657,7 +659,7 @@ func (r *goPackagesResolver) loadPackageNames(importPaths []string, srcDir strin
|
||||
func (r *goPackagesResolver) scan(refs references) ([]*pkg, error) {
|
||||
var loadQueries []string
|
||||
for pkgName := range refs {
|
||||
loadQueries = append(loadQueries, "name="+pkgName)
|
||||
loadQueries = append(loadQueries, "iamashamedtousethedisabledqueryname="+pkgName)
|
||||
}
|
||||
sort.Strings(loadQueries)
|
||||
cfg := r.env.newPackagesConfig(packages.LoadFiles)
|
||||
@ -741,18 +743,36 @@ func addExternalCandidates(pass *pass, refs references, filename string) error {
|
||||
return firstErr
|
||||
}
|
||||
|
||||
// importPathToNameBasic assumes the package name is the base of import path,
|
||||
// except that if the path ends in foo/vN, it assumes the package name is foo.
|
||||
func importPathToNameBasic(importPath, srcDir string) (packageName string) {
|
||||
// notIdentifier reports whether ch is an invalid identifier character.
|
||||
func notIdentifier(ch rune) bool {
|
||||
return !('a' <= ch && ch <= 'z' || 'A' <= ch && ch <= 'Z' ||
|
||||
'0' <= ch && ch <= '9' ||
|
||||
ch == '_' ||
|
||||
ch >= utf8.RuneSelf && (unicode.IsLetter(ch) || unicode.IsDigit(ch)))
|
||||
}
|
||||
|
||||
// importPathToAssumedName returns the assumed package name of an import path.
|
||||
// It does this using only string parsing of the import path.
|
||||
// It picks the last element of the path that does not look like a major
|
||||
// version, and then picks the valid identifier off the start of that element.
|
||||
// It is used to determine if a local rename should be added to an import for
|
||||
// clarity.
|
||||
// This function could be moved to a standard package and exported if we want
|
||||
// for use in other tools.
|
||||
func importPathToAssumedName(importPath string) string {
|
||||
base := path.Base(importPath)
|
||||
if strings.HasPrefix(base, "v") {
|
||||
if _, err := strconv.Atoi(base[1:]); err == nil {
|
||||
dir := path.Dir(importPath)
|
||||
if dir != "." {
|
||||
return path.Base(dir)
|
||||
base = path.Base(dir)
|
||||
}
|
||||
}
|
||||
}
|
||||
base = strings.TrimPrefix(base, "go-")
|
||||
if i := strings.IndexFunc(base, notIdentifier); i >= 0 {
|
||||
base = base[:i]
|
||||
}
|
||||
return base
|
||||
}
|
||||
|
||||
|
1
vendor/golang.org/x/tools/imports/mkstdlib.go
generated
vendored
1
vendor/golang.org/x/tools/imports/mkstdlib.go
generated
vendored
@ -58,6 +58,7 @@ func main() {
|
||||
mustOpen(api("go1.9.txt")),
|
||||
mustOpen(api("go1.10.txt")),
|
||||
mustOpen(api("go1.11.txt")),
|
||||
mustOpen(api("go1.12.txt")),
|
||||
)
|
||||
sc := bufio.NewScanner(f)
|
||||
|
||||
|
32
vendor/golang.org/x/tools/imports/zstdlib.go
generated
vendored
32
vendor/golang.org/x/tools/imports/zstdlib.go
generated
vendored
@ -112,6 +112,7 @@ var stdlib = map[string]map[string]bool{
|
||||
"Reader": true,
|
||||
"Repeat": true,
|
||||
"Replace": true,
|
||||
"ReplaceAll": true,
|
||||
"Runes": true,
|
||||
"Split": true,
|
||||
"SplitAfter": true,
|
||||
@ -441,6 +442,9 @@ var stdlib = map[string]map[string]bool{
|
||||
"RequireAnyClientCert": true,
|
||||
"Server": true,
|
||||
"SignatureScheme": true,
|
||||
"TLS_AES_128_GCM_SHA256": true,
|
||||
"TLS_AES_256_GCM_SHA384": true,
|
||||
"TLS_CHACHA20_POLY1305_SHA256": true,
|
||||
"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA": true,
|
||||
"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256": true,
|
||||
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256": true,
|
||||
@ -469,6 +473,7 @@ var stdlib = map[string]map[string]bool{
|
||||
"VersionTLS10": true,
|
||||
"VersionTLS11": true,
|
||||
"VersionTLS12": true,
|
||||
"VersionTLS13": true,
|
||||
"X25519": true,
|
||||
"X509KeyPair": true,
|
||||
},
|
||||
@ -1835,6 +1840,7 @@ var stdlib = map[string]map[string]bool{
|
||||
"R_PPC_UADDR32": true,
|
||||
"R_RISCV": true,
|
||||
"R_RISCV_32": true,
|
||||
"R_RISCV_32_PCREL": true,
|
||||
"R_RISCV_64": true,
|
||||
"R_RISCV_ADD16": true,
|
||||
"R_RISCV_ADD32": true,
|
||||
@ -2260,6 +2266,7 @@ var stdlib = map[string]map[string]bool{
|
||||
"IMAGE_FILE_MACHINE_AMD64": true,
|
||||
"IMAGE_FILE_MACHINE_ARM": true,
|
||||
"IMAGE_FILE_MACHINE_ARM64": true,
|
||||
"IMAGE_FILE_MACHINE_ARMNT": true,
|
||||
"IMAGE_FILE_MACHINE_EBC": true,
|
||||
"IMAGE_FILE_MACHINE_I386": true,
|
||||
"IMAGE_FILE_MACHINE_IA64": true,
|
||||
@ -2753,6 +2760,7 @@ var stdlib = map[string]map[string]bool{
|
||||
"New": true,
|
||||
"Note": true,
|
||||
"Package": true,
|
||||
"PreserveAST": true,
|
||||
"Synopsis": true,
|
||||
"ToHTML": true,
|
||||
"ToText": true,
|
||||
@ -2766,6 +2774,7 @@ var stdlib = map[string]map[string]bool{
|
||||
"go/importer": map[string]bool{
|
||||
"Default": true,
|
||||
"For": true,
|
||||
"ForCompiler": true,
|
||||
"Lookup": true,
|
||||
},
|
||||
"go/parser": map[string]bool{
|
||||
@ -3296,6 +3305,7 @@ var stdlib = map[string]map[string]bool{
|
||||
"SeekEnd": true,
|
||||
"SeekStart": true,
|
||||
"Seeker": true,
|
||||
"StringWriter": true,
|
||||
"TeeReader": true,
|
||||
"WriteCloser": true,
|
||||
"WriteSeeker": true,
|
||||
@ -3498,6 +3508,12 @@ var stdlib = map[string]map[string]bool{
|
||||
"Word": true,
|
||||
},
|
||||
"math/bits": map[string]bool{
|
||||
"Add": true,
|
||||
"Add32": true,
|
||||
"Add64": true,
|
||||
"Div": true,
|
||||
"Div32": true,
|
||||
"Div64": true,
|
||||
"LeadingZeros": true,
|
||||
"LeadingZeros16": true,
|
||||
"LeadingZeros32": true,
|
||||
@ -3508,6 +3524,9 @@ var stdlib = map[string]map[string]bool{
|
||||
"Len32": true,
|
||||
"Len64": true,
|
||||
"Len8": true,
|
||||
"Mul": true,
|
||||
"Mul32": true,
|
||||
"Mul64": true,
|
||||
"OnesCount": true,
|
||||
"OnesCount16": true,
|
||||
"OnesCount32": true,
|
||||
@ -3527,6 +3546,9 @@ var stdlib = map[string]map[string]bool{
|
||||
"RotateLeft32": true,
|
||||
"RotateLeft64": true,
|
||||
"RotateLeft8": true,
|
||||
"Sub": true,
|
||||
"Sub32": true,
|
||||
"Sub64": true,
|
||||
"TrailingZeros": true,
|
||||
"TrailingZeros16": true,
|
||||
"TrailingZeros32": true,
|
||||
@ -3870,6 +3892,7 @@ var stdlib = map[string]map[string]bool{
|
||||
"StatusTeapot": true,
|
||||
"StatusTemporaryRedirect": true,
|
||||
"StatusText": true,
|
||||
"StatusTooEarly": true,
|
||||
"StatusTooManyRequests": true,
|
||||
"StatusUnauthorized": true,
|
||||
"StatusUnavailableForLegalReasons": true,
|
||||
@ -4140,6 +4163,7 @@ var stdlib = map[string]map[string]bool{
|
||||
"Truncate": true,
|
||||
"Unsetenv": true,
|
||||
"UserCacheDir": true,
|
||||
"UserHomeDir": true,
|
||||
},
|
||||
"os/exec": map[string]bool{
|
||||
"Cmd": true,
|
||||
@ -4244,6 +4268,7 @@ var stdlib = map[string]map[string]bool{
|
||||
"MakeMapWithSize": true,
|
||||
"MakeSlice": true,
|
||||
"Map": true,
|
||||
"MapIter": true,
|
||||
"MapOf": true,
|
||||
"Method": true,
|
||||
"New": true,
|
||||
@ -4419,9 +4444,12 @@ var stdlib = map[string]map[string]bool{
|
||||
"Version": true,
|
||||
},
|
||||
"runtime/debug": map[string]bool{
|
||||
"BuildInfo": true,
|
||||
"FreeOSMemory": true,
|
||||
"GCStats": true,
|
||||
"Module": true,
|
||||
"PrintStack": true,
|
||||
"ReadBuildInfo": true,
|
||||
"ReadGCStats": true,
|
||||
"SetGCPercent": true,
|
||||
"SetMaxStack": true,
|
||||
@ -4547,6 +4575,7 @@ var stdlib = map[string]map[string]bool{
|
||||
"Reader": true,
|
||||
"Repeat": true,
|
||||
"Replace": true,
|
||||
"ReplaceAll": true,
|
||||
"Replacer": true,
|
||||
"Split": true,
|
||||
"SplitAfter": true,
|
||||
@ -6105,6 +6134,7 @@ var stdlib = map[string]map[string]bool{
|
||||
"FreeLibrary": true,
|
||||
"Fsid": true,
|
||||
"Fstat": true,
|
||||
"Fstatat": true,
|
||||
"Fstatfs": true,
|
||||
"Fstore_t": true,
|
||||
"Fsync": true,
|
||||
@ -9362,6 +9392,7 @@ var stdlib = map[string]map[string]bool{
|
||||
"Syscall": true,
|
||||
"Syscall12": true,
|
||||
"Syscall15": true,
|
||||
"Syscall18": true,
|
||||
"Syscall6": true,
|
||||
"Syscall9": true,
|
||||
"Sysctl": true,
|
||||
@ -9630,6 +9661,7 @@ var stdlib = map[string]map[string]bool{
|
||||
"TransmitFile": true,
|
||||
"TransmitFileBuffers": true,
|
||||
"Truncate": true,
|
||||
"UNIX_PATH_MAX": true,
|
||||
"USAGE_MATCH_TYPE_AND": true,
|
||||
"USAGE_MATCH_TYPE_OR": true,
|
||||
"UTF16FromString": true,
|
||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -192,7 +192,7 @@ golang.org/x/sys/windows
|
||||
golang.org/x/text/width
|
||||
golang.org/x/text/transform
|
||||
golang.org/x/text/unicode/norm
|
||||
# golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6
|
||||
# golang.org/x/tools v0.0.0-20190125232054-379209517ffe
|
||||
golang.org/x/tools/go/loader
|
||||
golang.org/x/tools/go/packages
|
||||
golang.org/x/tools/imports
|
||||
|
Loading…
x
Reference in New Issue
Block a user