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: Build constraints on the first line of a file are ignored #3730

Closed
gopherbot opened this issue Jun 12, 2012 · 3 comments
Closed

cmd/go: Build constraints on the first line of a file are ignored #3730

gopherbot opened this issue Jun 12, 2012 · 3 comments

Comments

@gopherbot
Copy link

by runningwild:

If there are no blank lines between the start of a file and a comment containing build
constraints those build constraints are ignored.

What steps will reproduce the problem?
Make two files, foo.go (no blank line before the build constraint):
// +build ignore
package main
func main() {
  println("Hi!")
}
and bar.go:
package main
func main() {
  println("Hi!")
}

then run "go build ." in that directory.

This fails because of duplicate definition of main().  If a blank line is inserted
before the build constraint in foo.go the compilation succeeds as expected (inserting
another line of comments is not sufficient).

Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
darwin, linux

Which version are you using?  (run 'go version')
go1
hg id: 817fde92780a
@axw
Copy link
Contributor

axw commented Jun 13, 2012

Comment 1:

It's because there's no space *after* the build constraint line. There's a comment in
the source to that effect, but nothing in the docs that I can see.
http://code.google.com/p/go/source/browse/src/pkg/go/build/build.go#656

@axw
Copy link
Contributor

axw commented Jun 13, 2012

Comment 2:

Oops, the behaviour (sorry missed the comment about inserting a leading space) doesn't
quite match the comment either.

@rsc
Copy link
Contributor

rsc commented Sep 12, 2012

Comment 4:

Status changed to Duplicate.

Merged into issue #3539.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
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