]> Cypherpunks repositories - gostls13.git/commit
go/ast: note that in BasicLit CHARs and STRINGs are quoted
authorAlberto Donizetti <alb.donizetti@gmail.com>
Mon, 27 Jul 2020 12:42:06 +0000 (14:42 +0200)
committerAlberto Donizetti <alb.donizetti@gmail.com>
Sun, 6 Sep 2020 20:23:50 +0000 (20:23 +0000)
commit5cc030aa1996762e48ce446001078ce6447f105e
tree3c1c90c008a864c2e073174e8d7b22fb950f4b0e
parent617f2c3e35cdc8483b950aa3ef18d92965d63197
go/ast: note that in BasicLit CHARs and STRINGs are quoted

The Value field of ast.BasicLit is a string field holding the literal
string. For CHARs and STRINGs, the BasicLit.Value literal includes
quotes, so to use the value in practise one will often need to Unquote
it.

Since this is a common gotcha (I've been bitten by this a few times),
document it, and suggest the use of the strconv.Unquote functions.

Fixes #39590

Change-Id: Ie3e13f5a2a71bb1b59e03bc5b3a16d8e2e7c01d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/244960
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
src/go/ast/ast.go