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 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 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 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
Member

@bcmills bcmills commented May 21, 2020

Duplicate of #37803

@bcmills bcmills marked this as a duplicate of #37803 May 21, 2020
@bcmills bcmills closed this May 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.