...
1
2
3
4
5 package json
6
7 import (
8 "strings"
9 )
10
11
12
13 type tagOptions string
14
15
16
17 func parseTag(tag string) (string, tagOptions) {
18 if idx := strings.Index(tag, ","); idx != -1 {
19 return tag[:idx], tagOptions(tag[idx+1:])
20 }
21 return tag, tagOptions("")
22 }
23
24
25
26
27 func (o tagOptions) Contains(optionName string) bool {
28 if len(o) == 0 {
29 return false
30 }
31 s := string(o)
32 for s != "" {
33 var next string
34 i := strings.Index(s, ",")
35 if i >= 0 {
36 s, next = s[:i], s[i+1:]
37 }
38 if s == optionName {
39 return true
40 }
41 s = next
42 }
43 return false
44 }
45
View as plain text