...

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

Documentation: cmd/go/testdata/script

     1# Regression test for golang.org/issue/28481:
     2# 'mod tidy' removed dependencies if the module root was
     3# within a directory named 'testdata' or '_foo'.
     4
     5env GO111MODULE=on
     6
     7# A module should be allowed in a directory named testdata.
     8cd $WORK/testdata
     9go mod init testdata.tld/foo
    10
    11# Getting a package within that module should resolve its dependencies.
    12go get
    13grep 'rsc.io/quote' go.mod
    14
    15# Tidying the module should preserve those dependencies.
    16go mod tidy
    17grep 'rsc.io/quote' go.mod
    18
    19[short] stop
    20
    21# Vendoring the module's dependencies should work too.
    22go mod vendor
    23exists vendor/rsc.io/quote
    24
    25# The same should work in directories with names starting with underscores.
    26cd $WORK/_ignored
    27go mod init testdata.tld/foo
    28
    29go get
    30grep 'rsc.io/quote' go.mod
    31
    32go mod tidy
    33grep 'rsc.io/quote' go.mod
    34
    35go mod vendor
    36exists vendor/rsc.io/quote
    37
    38-- $WORK/testdata/main.go --
    39package foo
    40
    41import _ "rsc.io/quote"
    42-- $WORK/_ignored/main.go --
    43package foo
    44
    45import _ "rsc.io/quote"

View as plain text