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: go generate incorrectly runs string consts. #20954

Closed
james-lawrence opened this issue Jul 8, 2017 · 3 comments
Closed

cmd/go: go generate incorrectly runs string consts. #20954

james-lawrence opened this issue Jul 8, 2017 · 3 comments

Comments

@james-lawrence
Copy link
Contributor

version: go1.8.3 linux/amd64

package main

const example = `
//go:generate echo hello world
`
go generate .
hello world
@ALTree
Copy link
Member

ALTree commented Jul 8, 2017

Thanks for the report.

In $ go generate -h:

[...]
Note that go generate does not parse the file, so lines that look
like directives in comments or multiline strings will be treated
as directives
.
[...]

Closing this, since it's not a bug.

@ALTree ALTree closed this as completed Jul 8, 2017
@james-lawrence
Copy link
Contributor Author

that might want to be re-evaluated. its odd and unexpected behaviour (even if documented). is there a reason for this choice?

@ALTree
Copy link
Member

ALTree commented Jul 8, 2017

I guess that one reason may be the fact that doing it this way does not require parsing the file. The doc hints at this:

Note that go generate does not parse the file

If you want a more authoritative answer, I think the right place to ask this is golang-dev: https://groups.google.com/forum/#!forum/golang-dev (we don't usually use the issue tracker for discussion).

@mikioh mikioh changed the title go:generate incorrectly runs string consts. cmd/go: go generate incorrectly runs string consts. Aug 2, 2017
@golang golang locked and limited conversation to collaborators Aug 2, 2018
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