...
1# https://golang.org/issue/44725: packages in std should have the same
2# dependencies regardless of whether they are listed from within or outside
3# GOROOT/src.
4
5env GOROOT=$WORK/goroot
6
7# Control case: net, viewed from outside the 'std' module,
8# should depend on vendor/golang.org/… instead of golang.org/….
9
10go list -deps net
11stdout '^vendor/golang.org/x/net'
12! stdout '^golang.org/x/net'
13cp stdout $WORK/net-deps.txt
14
15
16# It should still report the same package dependencies when viewed from
17# within GOROOT/src.
18
19cd $GOROOT/src
20
21go list -deps net
22stdout '^vendor/golang.org/x/net'
23! stdout '^golang.org/x/net'
24cmp stdout $WORK/net-deps.txt
25
26
27# However, 'go mod' and 'go get' subcommands should report the original module
28# dependencies, not the vendored packages.
29
30env GOWORK=off
31go mod why -m golang.org/x/net
32stdout '^# golang.org/x/net\nnet\ngolang.org/x/net'
33
34-- $WORK/goroot/src/go.mod --
35module std
36
37go 1.26
38
39require golang.org/x/net v0.1.0
40-- $WORK/goroot/src/go.sum --
41golang.org/x/net v0.1.0 h1:iUcD2VNMwNi3BZMUg2qIGo4aAass7E0R4eQNGK3hvc0=
42golang.org/x/net v0.1.0/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
43-- $WORK/goroot/src/vendor/modules.txt --
44# golang.org/x/net v0.1.0
45## explicit
46golang.org/x/net/dns/dnsmessage
47-- $WORK/goroot/src/vendor/modules.txt --
48# golang.org/x/net v0.1.0
49## explicit
50golang.org/x/net/dns/dnsmessage
51-- $WORK/goroot/src/vendor/golang.org/x/net/dns/dnsmessage/dnsmessage.go --
52package dnsmessage
53-- $WORK/goroot/src/net/net.go --
54package net
55
56import _ "golang.org/x/net/dns/dnsmessage"
View as plain text