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/vet: "possible malformed +build comment" check too strict #30252

Open
eliasnaur opened this Issue Feb 15, 2019 · 4 comments

Comments

Projects
None yet
5 participants
@eliasnaur
Copy link
Contributor

eliasnaur commented Feb 15, 2019

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

$ go version
go version devel +ffd096db2b Wed Feb 13 05:35:45 2019 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

I have a go generate line that prepends a +build comment to a C file:

//go:generate sed -i "1s;^;// +build linux,!android\\n\\n;" wayland_xdg_shell.c

What did you expect to see?

No warning from go vet or go test.

What did you see instead?

Running go vet or go test on the package results in:

os/os_wayland.go:14:1: possible malformed +build comment

I admit this is a special case.

@katiehockman

This comment has been minimized.

Copy link
Contributor

katiehockman commented Feb 15, 2019

@katiehockman katiehockman added this to the Unplanned milestone Feb 15, 2019

@alandonovan

This comment has been minimized.

Copy link
Contributor

alandonovan commented Feb 15, 2019

It may be a special case, but vet could certainly do better. The presence of both // and " to the left of //+build should be quite enough to make it clear that this is a not a +build comment.

@mvdan

This comment has been minimized.

Copy link
Member

mvdan commented Feb 15, 2019

Would it not be easier to skip lines beginning with //go:? It's very likely that the user is writing some form of compiler or tool directive in that case.

@adonovan

This comment has been minimized.

Copy link

adonovan commented Feb 15, 2019

I was going to say it seems rather too specific, but in fact the only comments vet looks at are those above the package declaration, excluding the package doc comment itself, which leaves only true +build declarations, copyright messages, and //go declarations. So I guess that would be fine.

But it wouldn't be hard to exclude any comments of the form //.*// +build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.