1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
11 // tagOptions is the string following a comma in a struct field's "json"
12 // tag, or the empty string. It does not include the leading comma.
13 type tagOptions
string
15 // parseTag splits a struct field's json tag into its name and
16 // comma-separated options.
17 func parseTag(tag
string) (string, tagOptions
) {
18 if idx
:= strings
.Index(tag
, ","); idx
!= -1 {
19 return tag
[:idx
], tagOptions(tag
[idx
+1:])
21 return tag
, tagOptions("")
24 // Contains reports whether a comma-separated list of options
25 // contains a particular substr flag. substr must be surrounded by a
26 // string boundary or commas.
27 func (o tagOptions
) Contains(optionName
string) bool {
34 i
:= strings
.Index(s
, ",")
36 s
, next
= s
[:i
], s
[i
+1:]