]> Cypherpunks repositories - gostls13.git/commitdiff
reflect: document multiple keys in struct tags
authorIan Lance Taylor <iant@golang.org>
Thu, 3 Dec 2020 02:25:19 +0000 (18:25 -0800)
committerIan Lance Taylor <iant@golang.org>
Mon, 7 Dec 2020 22:16:21 +0000 (22:16 +0000)
For #40281
Fixes #42959

Change-Id: Ibc4769fda1592a1373ec720ea30baf319c0a0136
Reviewed-on: https://go-review.googlesource.com/c/go/+/274448
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
src/reflect/type.go

index a2076bb3f1bf9dbf676107ef698aa09ecf1d38b0..1f1e70d485c840ed0d7b1e1d3087251ac5259e4c 100644 (file)
@@ -1104,12 +1104,16 @@ type StructField struct {
 
 // A StructTag is the tag string in a struct field.
 //
-// By convention, tag strings are a concatenation of
-// optionally space-separated key:"value" pairs.
-// Each key is a non-empty string consisting of non-control
-// characters other than space (U+0020 ' '), quote (U+0022 '"'),
-// and colon (U+003A ':').  Each value is quoted using U+0022 '"'
-// characters and Go string literal syntax.
+// By convention, tag strings are a mapping of keys to values.
+// The format is key:"value". Each key is a non-empty string consisting
+// of non-control characters other than space (U+0020 ' '),
+// quote (U+0022 '"'), and colon (U+003A ':'). Each value is quoted
+// using U+0022 '"' characters and Go string literal syntax.
+// Multiple key-value mappings are separated by zero or more spaces, as in
+//   key1:"value1" key2:"value2"
+// Multiple keys may map to a single shared value by separating the keys
+// with spaces, as in
+//   key1 key2:"value"
 type StructTag string
 
 // Get returns the value associated with key in the tag string.