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