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

cmd/go: go run cannot build a command in a module directory #33890

Closed
robpike opened this issue Aug 27, 2019 · 3 comments
Closed

cmd/go: go run cannot build a command in a module directory #33890

robpike opened this issue Aug 27, 2019 · 3 comments
Labels
FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@robpike
Copy link
Contributor

robpike commented Aug 27, 2019

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

Recent, pretty much 1.13.

$ go version
go version devel +5498fa90e9 Fri Aug 23 00:46:55 2019 +0000 darwin/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="/Users/r/Library/Caches/go-build"
GOENV="/Users/r/Library/Application Support/go/env"
GOEXE=""
GOFLAGS="-ldflags=-w -mod=readonly"
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/r"
GOPRIVATE=""
GOPROXY="direct"
GOROOT="/Users/r/go"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/Users/r/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/r/src/sos/go.mod"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/bf/qmf6xmzn7vs1gzv6g7mq_wfr0004fc/T/go-build281039180=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I cannot do go run file.go in a module directory, but I can in a non-module directory:

% go run v.go
v.go:14:2: found packages foo (foo_test.go) and main (v.go) in /Users/r/src/foo
% grep ignore v.go
v.go:3: // +build ignore
%

What did you expect to see?

It should run the program.

What did you see instead?

An error about conflicting packages.

@robpike
Copy link
Contributor Author

robpike commented Aug 27, 2019

Also, why is it complaining about a test file? It shouldn't even be looking at that.

@mvdan
Copy link
Member

mvdan commented Aug 28, 2019

go run was recently taught to build entire packages with their dependencies, so perhaps that's when this regression was introduced. CC @bcmills @jayconrod

@mvdan mvdan added modules NeedsFix The path to resolution is known, but the work has not been done. labels Aug 28, 2019
@bcmills bcmills modified the milestones: Go1.13, Go1.14 Aug 28, 2019
@robpike
Copy link
Contributor Author

robpike commented Sep 6, 2019

This was my mistake involving misuse of build tags.

@robpike robpike closed this as completed Sep 6, 2019
@golang golang locked and limited conversation to collaborators Sep 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants