...

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

Documentation: cmd/go/testdata/script

     1env GO111MODULE=on
     2
     3# We should not create a go.mod file unless the user ran 'go mod init' explicitly.
     4# However, we should suggest 'go mod init' if we can find an alternate config file.
     5cd $WORK/test/x
     6! go list .
     7stderr 'found .git/config in .*[/\\]test'
     8stderr '\s*cd \.\. && go mod init'
     9
    10# The command we suggested should succeed.
    11cd ..
    12go mod init
    13go list -m all
    14stdout '^m$'
    15
    16# We should not suggest creating a go.mod file in $GOROOT, even though there may be a .git/config there.
    17cd $GOROOT
    18! go list .
    19! stderr 'go mod init'
    20
    21# We should also not suggest creating a go.mod file in $GOROOT if its own
    22# .git/config has been stripped away and we find one in a parent directory.
    23# (https://golang.org/issue/34191)
    24env GOROOT=$WORK/parent/goroot
    25cd $GOROOT
    26! go list .
    27! stderr 'go mod init'
    28
    29cd $GOROOT/doc
    30! go list .
    31! stderr 'go mod init'
    32
    33-- $WORK/test/.git/config --
    34-- $WORK/test/x/x.go --
    35package x // import "m/x"
    36-- $WORK/parent/.git/config --
    37-- $WORK/parent/goroot/README --
    38This directory isn't really a GOROOT, but let's pretend that it is.
    39-- $WORK/parent/goroot/doc/README --
    40This is a subdirectory of our fake GOROOT.

View as plain text