-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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/ast: mention strconv.Unquote in BasicLit documentation #39590
Comments
Thanks for the report. A note from the Proposal Process doc:
Stress on "significant changes". I don't think a suggestion like this one has to go through the heavyweight Proposal Process, so I've changed this to a regular issue with a |
@ALTree |
The strconv docs do bring this up:
However, I agree that it's not really an answer, because many developers new to go/ast will not know the strconv package all that well. A quick mention in the ast package sounds good to me. |
I think you want to mention Unquote for string literals, UnquoteChar for rune literals, ParseInt for integer literals, and ParseFloat for floating point literals. I think that covers all the basic literal kinds, minus IMAG, which I'm not sure about. |
This could be okay for completeness' sake but to add a datapoint: I was bitten a couple times by the fact that, for strings, Value holds Mostly because you see that the interface holds a string, so you imagine that for an So just documenting the string-literal special case with a suggestion to call |
Change https://golang.org/cl/244960 mentions this issue: |
Agreed. We don't need to be exhaustive here. Will review now. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
https://golang.org/pkg/go/ast/#BasicLit
What did you expect to see?
I propose improve the document of
ast.BasicLit
.When
BasicLit.Kind
istoken.STRING
, we must callstrconv.Unquote
to get unquoted string value.So I think the document of
ast.BasicLit
should refer tostrconv.Unquote
.What did you see instead?
https://golang.org/pkg/go/ast/#BasicLit
The text was updated successfully, but these errors were encountered: