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
go/printer: rewrite import foo
to import "foo"
#9644
Comments
The spec simply wants a string literal there, so both string forms are permitted. It's fine to have gofmt produce only double-quoted strings. |
Maybe keep raw strings if the import has double quotes in it already. (which will be approximately 0% of programs in the wild) |
According to http://golang.org/ref/spec#Import_declarations, |
@minux The implementation restriction in http://golang.org/ref/spec#Import_declarations is already implemented (in gc I think, and in go/types for sure) and is applied to the runes of the string, but not the string's quotes. That is, both It's trivial to do this in gofmt and there's no need to be overly restrictive in the compiler. |
Right, so there is really no reason not to always rewrite import btw, my point about import path restrictions was replying to Brad's comment |
It might be that go/printer should rewrite
to
so that all import statements use double-quoted strings. This is unlikely in practice, but I found myself making this assumption in a textual rewriter (and we've made this assumption in commands that update old code.google.com subrepo imports) and I was surprised that the backquoted form gets through gofmt.
http://play.golang.org/p/XS-iKGjQWe
We should think about this for Go 1.5.
@griesemer
The text was updated successfully, but these errors were encountered: