1env OLD=$PWD 2 3# basic -C functionality 4cd $GOROOT/src/math 5go list -C ../strings 6stdout strings 7! go list -C ../nonexist 8stderr 'chdir.*nonexist' 9 10# check for -C in subcommands with custom flag parsing 11# cmd/go/chdir_test.go handles the normal ones more directly. 12 13# go doc 14go doc -C ../strings HasPrefix 15 16# go env 17go env -C $OLD/custom GOMOD 18stdout 'custom[\\/]go.mod' 19! go env -C ../nonexist 20stderr '^go: chdir ../nonexist: ' 21 22# go test 23go test -C ../strings -n 24stderr 'strings\.test' 25 26# go vet 27go vet -C ../strings -n 28stderr strings_test 29 30# -C must be first on command line (as of Go 1.21) 31! go test -n -C ../strings 32stderr '^invalid value "../strings" for flag -C: -C flag must be first flag on command line$' 33 34-- custom/go.mod -- 35module m 36