Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After exec cmd "go mod init $name",then go test will fail #39706

Closed
lbbxsxlz opened this issue Jun 19, 2020 · 1 comment
Closed

After exec cmd "go mod init $name",then go test will fail #39706

lbbxsxlz opened this issue Jun 19, 2020 · 1 comment

Comments

@lbbxsxlz
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.14.4 linux/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/lbbxsxlz/.cache/go-build"
GOENV="/home/lbbxsxlz/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/lbbxsxlz/gitWorkspace/gzCoredump:/home/lbbxsxlz/workspace/GO"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/home/lbbxsxlz/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/lbbxsxlz/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build749602966=/tmp/go-build -gno-record-gcc-switches"

What did you do?

go test elfreader
$GOPATH/go.mod exists but should not

What did you expect to see?

I want to know whether command "go mod init" is conflicted with "go test".
the cmd "go test" is depended on GOPATH.

What did you see instead?

@jayconrod
Copy link
Contributor

Since you don't have GO111MODULE set, it defaults to auto, and the go command will look for a go.mod file in parent directories to decide whether to build in module mode or GOPATH mode.

With auto, the file $GOPATH/go.mod must not exist. Based in your GOPATH, it may be either /home/lbbxsxlz/gitWorkspace/gzCoredump/src/go.mod or /home/lbbxsxlz/workspace/GO/src/go.mod. You can either remove it or set GO111MODULE=off in your environment to build in GOPATH mode.

It sounds like this is working as intended, so I'll close this issue. The golang-nuts mailing list and the Gophers Slack are the best places to ask questions.

@golang golang locked and limited conversation to collaborators Jun 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants