From 238274df4eee1752f51b288a11eddaf5365123bf Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 6 Sep 2016 17:26:15 -0700 Subject: [PATCH] go/constant: document that Value.String and ExactString return quoted strings This has always been the case but it was not obvious from the documentation. The reason for the quoting is that String() may return an abbreviated string, starting with double-quote (") but ending in ... (w/o a quote). The missing quote indicates the abbreviation (in contrast to a string ending in ..."). constant.StringVal can be used to obtain the unquoted string of a String Value. Change-Id: Id0ba45b6ff62b3e024386ba8d907d6b3a4fcb6d7 Reviewed-on: https://go-review.googlesource.com/28576 Reviewed-by: Alan Donovan --- src/go/constant/value.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/go/constant/value.go b/src/go/constant/value.go index ab10ae3299..90c04df88d 100644 --- a/src/go/constant/value.go +++ b/src/go/constant/value.go @@ -43,13 +43,14 @@ type Value interface { // Kind returns the value kind. Kind() Kind - // String returns a short, human-readable form of the value. + // String returns a short, quoted (human-readable) form of the value. // For numeric values, the result may be an approximation; // for String values the result may be a shortened string. // Use ExactString for a string representing a value exactly. String() string - // ExactString returns an exact, printable form of the value. + // ExactString returns an exact, quoted (human-readable) form of the value. + // If the Value is of Kind String, use StringVal to obtain the unquoted string. ExactString() string // Prevent external implementations. -- 2.48.1