-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
What version of Go are you using (go version)?
1.17 release notes
Does this issue reproduce with the latest release?
arguably no since the latest release, 1.16, does not have this function yet :)
What operating system and processor architecture are you using (go env)?
N/A
What did you do?
Read release notes and corresponding documentation.
What did you expect to see?
Documentation that I understand.
What did you see instead?
Documentation which confused me.
QuotedPrefix returns the quoted string (as understood by Unquote) at the prefix of s. If s does not start with a valid quoted string, QuotedPrefix returns an error.
It is unclear to me whether "as understood by Unquote" means "an initial prefix which Unquote would think was a valid quoted string that it could unquote", or "the result of unquoting such an initial prefix".
For instance, consider the string:
"foo"bar
I would guess that QuotedPrefix, called on this, would yield either "foo" or foo, but i don't know which; both are "the quoted string (as understood by Unquote)". I think the intent is probably "foo", because that seems more likely to be useful -- given the other string, I don't have a way to trim that prefix from the parent string, because I don't know how it looked in the parent string. On the other hand, it seems weird to go to all the trouble of separating it out and parsing it as though unquoting, and not actually do the unquoting, so I don't know.
I feel like QuotedPrefix should probably return (prefix string, remainder string, error). I'm less sure about dequoting; the dequoting operation presumably causes allocation. (It'd be neat, though, to be able to inquire as to the length the dequoted string would have...)