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/gofmt: honor build tags, especially release tags #21337
Comments
@dvyukov for now, I've added for you a PR at google/syzkaller#329, please test it out on Travis CI and it should be able to run the tests against Go1.9rc1 as well as tip, instead of against 1.8.1 on which aliases are gonna trip out, and when Go1.9 is released then we can update from 1.9rc1 to 1.9. |
For golang/go#21337. Since the introduction of aliases is in Go1.9 but Go1.9 hasn't yet been officially released, let's use go1.9rc1 which is supported on Travis CI by their Go version getter gimme https://github.com/travis-ci/gimme instead of against go1.8.1. This solves the problem on which our vendored code is updated using Go1.9* syntax but is running against Go1.8* in Travis CI tests.
For golang/go#21337. Since the introduction of aliases is in Go1.9 but Go1.9 hasn't yet been officially released, let's use go1.9rc1 which is supported on Travis CI by their Go version getter gimme https://github.com/travis-ci/gimme instead of against go1.8.1. This solves the problem on which our vendored code is updated using Go1.9* syntax but is running against Go1.8* in Travis CI tests.
That's unfortunate. Even if we did a Go 1.8.x release for this, user also wouldn't get that. So really the answer is for people to move to Go 1.9 if they use deps using Go 1.9 (even +build conditional Go 1.9) features I guess. This is something to keep in mind for rolling out any future language changes. |
It seems that x/net/context added type aliases too early. I mean it's a widely used package and 1.9 is not even released. |
I don't think so. The whole point of +build tags is so we can do just that. I think the bug here is that gofmt should respect That is, if I'm running |
gofmt doesn't touch a file if it contains syntax errors, but I'm not convinced that it shouldn't complain. A script could trivially discard any error output. Or, perhaps for manual use, maybe there could be a |
@griesemer you mean always running go fmt as: |
@dvyukov Not always, but perhaps in situations where we don't care about errors. |
Still exists in
Found this bug while generating swagger doc for my api
Also Duting go fmt
here what go19.go file looks like
|
@sh0umik Yes, that specific problem with gofmt is fixed in the 1.9 release. This issue is about whether gofmt should somehow honor build tags to avoid this kind of crash in the future. |
I don't think we should try to make gofmt or "go fmt" detect "files from the future" by parsing build tags. Typically you run gofmt on your own code. |
I got this error today during make generate. My code is rebased on 8bd6bd63 ('prog: allow escaping paths but don't generate them'). vendor/google.golang.org/grpc/status/status.go Any suggestion how to move on? |
Hi Noa, We require Go 1.9+ because of this, please upgrade. Also if you are going to do any changes, then 1.9 or 1.10, but not 1.11 because of breaking changes in gofmt output. |
go version go1.8.3 linux/amd64
I've pulled latest versions of all deps, including golang.org/x/net/context. Now 1.8 go fmt ./... fails with:
https://travis-ci.org/google/syzkaller/builds/262119828
Not sure what exactly part is guilty. But I guess it will affect a bunch of users.
Go1.9 is not released yet, and I am not sure when it will appear on travis-ci.org.
go fmt ignores build tags, which is reasonable.
1.8 go does not ignore vendor dirs.
I cannot not update packages because our cloud APIs continue to break public interfaces.
Any way we can resolve this?
The text was updated successfully, but these errors were encountered: