Skip to content

strconv: Document that Unquote("''") doesn't return error #64280

@johannes-riecken

Description

@johannes-riecken

What version of Go are you using (go version)?

$ go version
go version go1.21.4 darwin/arm64

The documentation for strconv.Unquote currently reads

package strconv // import "strconv"

func Unquote(s string) (string, error)
Unquote interprets s as a single-quoted, double-quoted, or backquoted
Go string literal, returning the string value that s quotes. (If s is
single-quoted, it would be a Go character literal; Unquote returns the
corresponding one-character string.)

However, strconv.Unquote("''") equals the empty string, whereas from the documentation one would assume this to return an invalid-syntax error. Perhaps a reasonable addition to the documentation would be

If s is an empty pair of single quotes, Unquote returns the empty string.

Metadata

Metadata

Assignees

Labels

DocumentationIssues describing a change to documentation.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions