...

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

Documentation: cmd/go/testdata/script

     1env GO111MODULE=on
     2cp go.mod.orig go.mod
     3
     4# relative and absolute paths must be within the main module.
     5! go get ..
     6stderr '^go: \.\. \('$WORK'[/\\]gopath\) is not within module rooted at '$WORK'[/\\]gopath[/\\]src$'
     7! go get $WORK
     8stderr '^go: '$WORK' is not within module rooted at '$WORK'[/\\]gopath[/\\]src$'
     9! go get ../...
    10stderr '^go: \.\./\.\.\. \('$WORK'[/\\]gopath([/\\]...)?\) is not within module rooted at '$WORK'[/\\]gopath[/\\]src$'
    11! go get $WORK/...
    12stderr '^go: '$WORK'[/\\]\.\.\. is not within module rooted at '$WORK'[/\\]gopath[/\\]src$'
    13
    14# @patch and @latest within the main module refer to the current version.
    15# The main module won't be upgraded, but missing dependencies will be added.
    16go get rsc.io/x
    17grep 'rsc.io/quote v1.5.2' go.mod
    18go get rsc.io/x@upgrade
    19grep 'rsc.io/quote v1.5.2' go.mod
    20cp go.mod.orig go.mod
    21go get rsc.io/x@patch
    22grep 'rsc.io/quote v1.5.2' go.mod
    23cp go.mod.orig go.mod
    24
    25
    26# Upgrading a package pattern not contained in the main module should not
    27# attempt to upgrade the main module.
    28go get rsc.io/quote/...@v1.5.1
    29grep 'rsc.io/quote v1.5.1' go.mod
    30
    31
    32# The main module cannot be updated to a specific version.
    33! go get rsc.io@v0.1.0
    34stderr '^go: can''t request version "v0.1.0" of the main module \(rsc.io\)$'
    35
    36# A package in the main module can't be upgraded either.
    37! go get rsc.io/x@v0.1.0
    38stderr '^go: package rsc.io/x is in the main module, so can''t request version v0.1.0$'
    39
    40# Nor can a pattern matching packages in the main module.
    41! go get rsc.io/x/...@latest
    42stderr '^go: pattern rsc.io/x/... matches package rsc.io/x in the main module, so can''t request version latest$'
    43
    44-- go.mod.orig --
    45module rsc.io
    46
    47go 1.13
    48-- x/x.go --
    49package x
    50
    51import _ "rsc.io/quote"

View as plain text