Skip to content

+build tags not honored #31878

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

Closed
jinfengnarvar opened this issue May 7, 2019 · 1 comment
Closed

+build tags not honored #31878

jinfengnarvar opened this issue May 7, 2019 · 1 comment

Comments

@jinfengnarvar
Copy link

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

$ go version
go version go1.12.4 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
GOARCH="amd64"
GOBIN="/Users/jinfeng/dev/narvar/go/bin"
GOCACHE="/Users/jinfeng/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/jinfeng/dev/narvar/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/opt/go/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/opt/go/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/jinfeng/dev/narvar/NarvarGolangApps/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/x2/6yhw9qq129gffvpx90dv5gyw0000gp/T/go-build705269767=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Here is the package structure and file content:

$ tree
.
├── n1.go
└── n2.go

0 directories, 2 files
$ cat n1.go 
package ntest

func DoSomething() error {
    return nil
}
$ cat n2.go 
// +build ignore

package ntest

func DoSomething() error {
    return nil
}
$ go build *.go
# command-line-arguments
./n2.go:5:6: DoSomething redeclared in this block
	previous declaration at ./n1.go:3:20
$

What did you expect to see?

go build *.go succeeds

What did you see instead?

go build *.go failed

@mvdan
Copy link
Member

mvdan commented May 7, 2019

See go help packages. I'm pretty sure this has been raised multiple times before.

As a special case, if the package list is a list of .go files from a
single directory, the command is applied to a single synthesized
package made up of exactly those files, ignoring any build constraints
in those files and ignoring any other files in the directory.

@mvdan mvdan closed this as completed May 7, 2019
@golang golang locked and limited conversation to collaborators May 6, 2020
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