diff options
author | Cherry Zhang <cherryyz@google.com> | 2020-10-28 09:12:20 -0400 |
---|---|---|
committer | Cherry Zhang <cherryyz@google.com> | 2020-10-28 09:12:20 -0400 |
commit | a16e30d162c1c7408db7821e7b9513cefa09c6ca (patch) | |
tree | af752ba9ba44c547df39bb0af9bff79f610ba9d5 /src/go/build/deps_test.go | |
parent | 91e4d2d57bc341dd82c98247117114c851380aef (diff) | |
parent | cf6cfba4d5358404dd890f6025e573a4b2156543 (diff) | |
download | go-git-dev.link.tar.gz |
[dev.link] all: merge branch 'master' into dev.linkdev.link
Clean merge.
Change-Id: Ia7b2808bc649790198d34c226a61d9e569084dc5
Diffstat (limited to 'src/go/build/deps_test.go')
-rw-r--r-- | src/go/build/deps_test.go | 58 |
1 files changed, 37 insertions, 21 deletions
diff --git a/src/go/build/deps_test.go b/src/go/build/deps_test.go index fa8ecf10f4..b26b2bd199 100644 --- a/src/go/build/deps_test.go +++ b/src/go/build/deps_test.go @@ -11,12 +11,12 @@ import ( "bytes" "fmt" "internal/testenv" + "io/fs" "io/ioutil" "os" "path/filepath" "runtime" "sort" - "strconv" "strings" "testing" ) @@ -99,10 +99,16 @@ var depsRules = ` RUNTIME < io; + syscall !< io; reflect !< sort; + RUNTIME, unicode/utf8 + < path; + + unicode !< path; + # SYSCALL is RUNTIME plus the packages necessary for basic system calls. - RUNTIME, unicode/utf8, unicode/utf16, io + RUNTIME, unicode/utf8, unicode/utf16 < internal/syscall/windows/sysdll, syscall/js < syscall < internal/syscall/unix, internal/syscall/windows, internal/syscall/windows/registry @@ -116,6 +122,9 @@ var depsRules = ` < context < TIME; + TIME, io, path, sort + < io/fs; + # MATH is RUNTIME plus the basic math packages. RUNTIME < math @@ -129,6 +138,9 @@ var depsRules = ` MATH < math/rand; + MATH + < runtime/metrics; + MATH, unicode/utf8 < strconv; @@ -137,7 +149,7 @@ var depsRules = ` # STR is basic string and buffer manipulation. RUNTIME, io, unicode/utf8, unicode/utf16, unicode < bytes, strings - < bufio, path; + < bufio; bufio, path, strconv < STR; @@ -145,7 +157,7 @@ var depsRules = ` # OS is basic OS access, including helpers (path/filepath, os/exec, etc). # OS includes string routines, but those must be layered above package os. # OS does not include reflection. - TIME, io, sort + io/fs < internal/testlog < internal/poll < os @@ -155,7 +167,9 @@ var depsRules = ` os/signal, STR < path/filepath - < io/ioutil, os/exec + < io/ioutil, os/exec; + + io/ioutil, os/exec, os/signal < OS; reflect !< OS; @@ -318,7 +332,6 @@ var depsRules = ` # so large dependencies must be kept out. # This is a long-looking list but most of these # are small with few dependencies. - # math/rand should probably be removed at some point. CGO, golang.org/x/net/dns/dnsmessage, golang.org/x/net/lif, @@ -327,11 +340,11 @@ var depsRules = ` internal/poll, internal/singleflight, internal/race, - math/rand, os < net; fmt, unicode !< net; + math/rand !< net; # net uses runtime instead # NET is net plus net-helper packages. FMT, net @@ -449,7 +462,7 @@ var depsRules = ` OS, compress/gzip, regexp < internal/profile; - html/template, internal/profile, net/http, runtime/pprof, runtime/trace + html, internal/profile, net/http, runtime/pprof, runtime/trace < net/http/pprof; # RPC @@ -457,14 +470,19 @@ var depsRules = ` < net/rpc < net/rpc/jsonrpc; + # System Information + internal/cpu, sync + < internal/sysinfo; + # Test-only log - < testing/iotest; + < testing/iotest + < testing/fstest; FMT, flag, math/rand < testing/quick; - FMT, flag, runtime/debug, runtime/trace + FMT, flag, runtime/debug, runtime/trace, internal/sysinfo < testing; internal/testlog, runtime/pprof, regexp @@ -479,7 +497,7 @@ var depsRules = ` CGO, OS, fmt < os/signal/internal/pty; - NET, testing + NET, testing, math/rand < golang.org/x/net/nettest; FMT, container/heap, math/rand @@ -492,7 +510,7 @@ func listStdPkgs(goroot string) ([]string, error) { var pkgs []string src := filepath.Join(goroot, "src") + string(filepath.Separator) - walkFn := func(path string, fi os.FileInfo, err error) error { + walkFn := func(path string, fi fs.FileInfo, err error) error { if err != nil || !fi.IsDir() || path == src { return nil } @@ -594,24 +612,22 @@ func findImports(pkg string) ([]string, error) { if !strings.HasSuffix(name, ".go") || strings.HasSuffix(name, "_test.go") { continue } - f, err := os.Open(filepath.Join(dir, name)) + var info fileInfo + info.name = filepath.Join(dir, name) + f, err := os.Open(info.name) if err != nil { return nil, err } - var imp []string - data, err := readImports(f, false, &imp) + err = readGoInfo(f, &info) f.Close() if err != nil { return nil, fmt.Errorf("reading %v: %v", name, err) } - if bytes.Contains(data, buildIgnore) { + if bytes.Contains(info.header, buildIgnore) { continue } - for _, quoted := range imp { - path, err := strconv.Unquote(quoted) - if err != nil { - continue - } + for _, imp := range info.imports { + path := imp.path if !haveImport[path] { haveImport[path] = true imports = append(imports, path) |