]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blob - vendor/github.com/vmihailenco/msgpack/tag.go
Upgrade to 0.12
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / vmihailenco / msgpack / tag.go
1 package msgpack
2
3 import (
4 "strings"
5 )
6
7 type tagOptions string
8
9 func (o tagOptions) Get(name string) (string, bool) {
10 s := string(o)
11 for len(s) > 0 {
12 var next string
13 idx := strings.IndexByte(s, ',')
14 if idx >= 0 {
15 s, next = s[:idx], s[idx+1:]
16 }
17 if strings.HasPrefix(s, name) {
18 return s[len(name):], true
19 }
20 s = next
21 }
22 return "", false
23 }
24
25 func (o tagOptions) Contains(name string) bool {
26 _, ok := o.Get(name)
27 return ok
28 }
29
30 func parseTag(tag string) (string, tagOptions) {
31 if idx := strings.IndexByte(tag, ','); idx != -1 {
32 name := tag[:idx]
33 if strings.IndexByte(name, ':') == -1 {
34 return name, tagOptions(tag[idx+1:])
35 }
36 }
37
38 if strings.IndexByte(tag, ':') == -1 {
39 return tag, ""
40 }
41 return "", tagOptions(tag)
42 }