aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/vmihailenco/msgpack/tag.go
diff options
context:
space:
mode:
authorNathan Dench <ndenc2@gmail.com>2019-05-24 15:16:44 +1000
committerNathan Dench <ndenc2@gmail.com>2019-05-24 15:16:44 +1000
commit107c1cdb09c575aa2f61d97f48d8587eb6bada4c (patch)
treeca7d008643efc555c388baeaf1d986e0b6b3e28c /vendor/github.com/vmihailenco/msgpack/tag.go
parent844b5a68d8af4791755b8f0ad293cc99f5959183 (diff)
downloadterraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.gz
terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.zst
terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.zip
Upgrade to 0.12
Diffstat (limited to 'vendor/github.com/vmihailenco/msgpack/tag.go')
-rw-r--r--vendor/github.com/vmihailenco/msgpack/tag.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/vendor/github.com/vmihailenco/msgpack/tag.go b/vendor/github.com/vmihailenco/msgpack/tag.go
new file mode 100644
index 0000000..48e6f94
--- /dev/null
+++ b/vendor/github.com/vmihailenco/msgpack/tag.go
@@ -0,0 +1,42 @@
1package msgpack
2
3import (
4 "strings"
5)
6
7type tagOptions string
8
9func (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
25func (o tagOptions) Contains(name string) bool {
26 _, ok := o.Get(name)
27 return ok
28}
29
30func 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}