зеркало из https://github.com/golang/tools.git
imports: minor fixes
These are mostly comments for CL 24941 that didn't get sent quickly enough. strings.Trim(`\"`) works, but by accident. It trims all leading and trailing "s and \s, but there are never leading or trailing \s. Semantic line breaks and punctuation cleanup. The reflow of comments in the pkgName == "main" if block is to silence this spurious vet failure: fix.go:247: +build comment must appear before package clause and be followed by a blank line Plain sync.Once values are enough. Change-Id: I241f3025031b6f21605da78ea52066713a203327 Reviewed-on: https://go-review.googlesource.com/24983 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Родитель
c550f66b0b
Коммит
6d32be89d5
|
@ -83,7 +83,7 @@ func fixImports(fset *token.FileSet, f *ast.File, filename string) (added []stri
|
|||
decls[v.Name.Name] = v
|
||||
break
|
||||
}
|
||||
ipath := strings.Trim(v.Path.Value, `\"`)
|
||||
ipath := strings.Trim(v.Path.Value, `"`)
|
||||
if ipath == "C" {
|
||||
break
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ func importPathToNameBasic(importPath, srcDir string) (packageName string) {
|
|||
// importPathToNameGoPath finds out the actual package name, as declared in its .go files.
|
||||
// If there's a problem, it falls back to using importPathToNameBasic.
|
||||
func importPathToNameGoPath(importPath, srcDir string) (packageName string) {
|
||||
// Fast path for standard library without going to disk:
|
||||
// Fast path for standard library without going to disk.
|
||||
if pkg, ok := stdImportPackage[importPath]; ok {
|
||||
return pkg
|
||||
}
|
||||
|
@ -243,10 +243,8 @@ func importPathToNameGoPathParse(importPath, srcDir string) (packageName string,
|
|||
continue
|
||||
}
|
||||
if pkgName == "main" {
|
||||
// Also skip package main, assuming it's a
|
||||
// +build ignore generator or example. Since
|
||||
// you can't import a package main anyway,
|
||||
// there's no harm here.
|
||||
// Also skip package main, assuming it's a +build ignore generator or example.
|
||||
// Since you can't import a package main anyway, there's no harm here.
|
||||
continue
|
||||
}
|
||||
return pkgName, nil
|
||||
|
@ -272,9 +270,9 @@ func init() {
|
|||
// Directory-scanning state.
|
||||
var (
|
||||
// scanGoRootOnce guards calling scanGoRoot (for $GOROOT)
|
||||
scanGoRootOnce = &sync.Once{}
|
||||
scanGoRootOnce sync.Once
|
||||
// scanGoPathOnce guards calling scanGoPath (for $GOPATH)
|
||||
scanGoPathOnce = &sync.Once{}
|
||||
scanGoPathOnce sync.Once
|
||||
|
||||
dirScanMu sync.RWMutex
|
||||
dirScan map[string]*pkg // abs dir path => *pkg
|
||||
|
@ -615,8 +613,8 @@ func loadExportsGoPath(expectPackage, dir string) map[string]bool {
|
|||
// to satisfy uses of pkg.X in the file.
|
||||
var findImport func(pkgName string, symbols map[string]bool, filename string) (foundPkg string, rename bool, err error) = findImportGoPath
|
||||
|
||||
// findImportGoPath is the normal implementation of findImport. (Some
|
||||
// companies have their own internally)
|
||||
// findImportGoPath is the normal implementation of findImport.
|
||||
// (Some companies have their own internally.)
|
||||
func findImportGoPath(pkgName string, symbols map[string]bool, filename string) (foundPkg string, rename bool, err error) {
|
||||
// Fast path for the standard library.
|
||||
// In the common case we hopefully never have to scan the GOPATH, which can
|
||||
|
|
|
@ -982,8 +982,8 @@ type Buffer2 struct {}
|
|||
|
||||
func withEmptyGoPath(fn func()) {
|
||||
dirScanMu.Lock()
|
||||
scanGoRootOnce = &sync.Once{}
|
||||
scanGoPathOnce = &sync.Once{}
|
||||
scanGoRootOnce = sync.Once{}
|
||||
scanGoPathOnce = sync.Once{}
|
||||
dirScan = nil
|
||||
ignoredDirs = nil
|
||||
dirScanMu.Unlock()
|
||||
|
|
Загрузка…
Ссылка в новой задаче