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

go build -tags broken #39188

Closed
fengttt opened this issue May 21, 2020 · 3 comments
Closed

go build -tags broken #39188

fengttt opened this issue May 21, 2020 · 3 comments

Comments

@fengttt
Copy link

fengttt commented May 21, 2020

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

$ go version 1.14.2

Does this issue reproduce with the latest release?

Yes

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

Linux, amd64

go env Output
$ go env

What did you do?

It seems go build -tags is broken. In the following, I have three simple files, a.go, b.go, main.go
go build builds fine, go build -tags xxxdbg builds fine, but go build -tags -xxxopt fail (CHK redefined)

[ftian@localhost tmp]$ cat *.go
// +build xxxdbg
// -- this is a.go
package main

func CHK(err error) {
	if err != nil {
		panic(err)
	}
}
// +build xxxopt
// -- this is b.go
package main

func CHK(err error) {
}

// -- this is main.go
package main


import (
	"fmt"
)

func main() {
	CHK(fmt.Errorf("This is an error."));
}

What did you expect to see?

go build -tags xxxdbg builds OK.
go build -tags xxxopt builds OK.
go build FAIL, CHK not defined

What did you see instead?

go build -tags xxxdbg builds OK
go build -tags xxxopt fails, CHK redeclared
go build build OK

@fengttt
Copy link
Author

fengttt commented May 21, 2020

Regardless, I expect -tags xxxopt and -tags xxxdbg behave the same -- either both succeed, or both fail.

@davecheney
Copy link
Contributor

davecheney commented May 21, 2020

(~/src) % go vet a.go
# command-line-arguments
./a.go:1:1: +build comment must appear before package clause and be followed by a blank line

@bcmills
Copy link
Contributor

bcmills commented May 21, 2020

Duplicate of #37803

@bcmills bcmills marked this as a duplicate of #37803 May 21, 2020
@bcmills bcmills closed this as completed May 21, 2020
@golang golang locked and limited conversation to collaborators May 21, 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

4 participants