mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-06 09:06:44 +00:00
![Riley Karson](/assets/img/avatar_default.png)
```bash GO111MODULE=on go get github.com/hashicorp/terraform@pluginsdk-v0.12-early7 GO111MODULE=on go mod vendor GO111MODULE=on go mod tidy ```
43 lines
746 B
Go
43 lines
746 B
Go
package msgpack
|
|
|
|
import (
|
|
"strings"
|
|
)
|
|
|
|
type tagOptions string
|
|
|
|
func (o tagOptions) Get(name string) (string, bool) {
|
|
s := string(o)
|
|
for len(s) > 0 {
|
|
var next string
|
|
idx := strings.IndexByte(s, ',')
|
|
if idx >= 0 {
|
|
s, next = s[:idx], s[idx+1:]
|
|
}
|
|
if strings.HasPrefix(s, name) {
|
|
return s[len(name):], true
|
|
}
|
|
s = next
|
|
}
|
|
return "", false
|
|
}
|
|
|
|
func (o tagOptions) Contains(name string) bool {
|
|
_, ok := o.Get(name)
|
|
return ok
|
|
}
|
|
|
|
func parseTag(tag string) (string, tagOptions) {
|
|
if idx := strings.IndexByte(tag, ','); idx != -1 {
|
|
name := tag[:idx]
|
|
if strings.IndexByte(name, ':') == -1 {
|
|
return name, tagOptions(tag[idx+1:])
|
|
}
|
|
}
|
|
|
|
if strings.IndexByte(tag, ':') == -1 {
|
|
return tag, ""
|
|
}
|
|
return "", tagOptions(tag)
|
|
}
|