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
Milestone

Comments

@robpike
Copy link
Contributor

@robpike 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

This comment has been minimized.

Copy link
Contributor Author

@robpike robpike commented Aug 27, 2019

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

@mvdan

This comment has been minimized.

Copy link
Member

@mvdan 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

@robpike

This comment has been minimized.

Copy link
Contributor Author

@robpike robpike commented Sep 6, 2019

This was my mistake involving misuse of build tags.

@robpike robpike closed this Sep 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.