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: A general comment invalidates a '+build' magic comment #9434

Closed
hajimehoshi opened this issue Dec 24, 2014 · 7 comments
Closed

cmd/go: A general comment invalidates a '+build' magic comment #9434

hajimehoshi opened this issue Dec 24, 2014 · 7 comments

Comments

@hajimehoshi
Copy link
Member

  • What version of Go are you using (go version)?
    go version go1.4 darwin/amd64
  • What operating system and processor architecture are you using?
    OS X 10.10.1
  • What did you do?
    Try to execute 'go build .' with two files:

main.go

/**/
// +build ignore
package main
func main() {
}

foo.go

package  foo
  • What did you expect to see?
    Ignore main.go (package main) when building or other tools. In fact, it worked without the general comments (/**/)
  • What did you see instead?
    can't load package: package .: found packages foo.go (foo) and main.go (main) in ...
@minux
Copy link
Member

minux commented Dec 24, 2014

You need to leave one blank line between // +build and package main,
otherwise that comment will be treated as package docs for package main.

@minux minux closed this as completed Dec 24, 2014
@hajimehoshi
Copy link
Member Author

I left one blank line between // + build and package main but the problem remains.

@minux
Copy link
Member

minux commented Dec 24, 2014

I can't reproduce the problem.

$ mkdir foo
$ cd foo
$ cat > a.go <<EOF
// comment
// +build ignore

package main
EOF
$ echo "package foo" > b.go
$ go build && echo ok
ok
$ go build . && echo ok
ok

@hajimehoshi
Copy link
Member Author

$ cat > a.go <<EOF
// comment
// +build ignore

package main

Please try with a general comment (/**/), not a line comment.

@minux
Copy link
Member

minux commented Dec 24, 2014

please see http://golang.org/pkg/go/build/#hdr-Build_Constraints,
only line comments are supported before // +build.

@hajimehoshi
Copy link
Member Author

Hmm, OK, this behavior I reported seems expected. Sorry for bothering you. Thank you very much.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
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