...

Text file src/cmd/go/testdata/script/mod_get_indirect.txt

Documentation: cmd/go/testdata/script

     1env GO111MODULE=on
     2[short] skip
     3
     4# get -u should not upgrade anything, since the package
     5# in the current directory doesn't import anything.
     6go get -u
     7go list -m all
     8stdout 'quote v1.5.1$'
     9grep 'rsc.io/quote v1.5.1$' go.mod
    10
    11# get -u should find quote v1.5.2 once there is a use.
    12cp $WORK/tmp/usequote.go x.go
    13go get -u
    14go list -m all
    15stdout 'quote v1.5.2$'
    16grep 'rsc.io/quote v1.5.2$' go.mod
    17
    18# it should also update x/text later than requested by v1.5.2
    19go list -m -f '{{.Path}} {{.Version}}{{if .Indirect}} // indirect{{end}}' all
    20stdout '^golang.org/x/text [v0-9a-f\.-]+ // indirect'
    21grep 'golang.org/x/text [v0-9a-f\.-]+ // indirect' go.mod
    22
    23# importing an empty module root as a package does not remove indirect tag.
    24cp $WORK/tmp/usetext.go x.go
    25go list -e
    26grep 'golang.org/x/text v0.3.0 // indirect$' go.mod
    27
    28# indirect tag should be removed upon seeing direct import.
    29cp $WORK/tmp/uselang.go x.go
    30go get
    31grep 'rsc.io/quote v1.5.2$' go.mod
    32grep 'golang.org/x/text [v0-9a-f\.-]+$' go.mod
    33
    34# indirect tag should be added by go mod tidy
    35cp $WORK/tmp/usequote.go x.go
    36go mod tidy
    37grep 'rsc.io/quote v1.5.2$' go.mod
    38grep 'golang.org/x/text [v0-9a-f\.-]+ // indirect' go.mod
    39
    40# requirement should be dropped entirely if not needed
    41cp $WORK/tmp/uselang.go x.go
    42go mod tidy
    43! grep rsc.io/quote go.mod
    44grep 'golang.org/x/text [v0-9a-f\.-]+$' go.mod
    45
    46-- go.mod --
    47module x
    48require rsc.io/quote v1.5.1
    49-- x.go --
    50package x
    51-- $WORK/tmp/usetext.go --
    52package x
    53import _ "golang.org/x/text"
    54-- $WORK/tmp/uselang.go --
    55package x
    56import _ "golang.org/x/text/language"
    57-- $WORK/tmp/usequote.go --
    58package x
    59import _ "rsc.io/quote"

View as plain text