]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blame - vendor/github.com/zclconf/go-cty/cty/gocty/helpers.go
update vendor and go.mod
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / zclconf / go-cty / cty / gocty / helpers.go
CommitLineData
15c0b25d
AP
1package gocty
2
3import (
4 "math/big"
5 "reflect"
6
7 "github.com/zclconf/go-cty/cty"
8 "github.com/zclconf/go-cty/cty/set"
9)
10
11var valueType = reflect.TypeOf(cty.Value{})
12var typeType = reflect.TypeOf(cty.Type{})
13
14var setType = reflect.TypeOf(set.Set{})
15
16var bigFloatType = reflect.TypeOf(big.Float{})
17var bigIntType = reflect.TypeOf(big.Int{})
18
19var emptyInterfaceType = reflect.TypeOf(interface{}(nil))
20
21var stringType = reflect.TypeOf("")
22
23// structTagIndices interrogates the fields of the given type (which must
24// be a struct type, or we'll panic) and returns a map from the cty
25// attribute names declared via struct tags to the indices of the
26// fields holding those tags.
27//
28// This function will panic if two fields within the struct are tagged with
29// the same cty attribute name.
30func structTagIndices(st reflect.Type) map[string]int {
31 ct := st.NumField()
32 ret := make(map[string]int, ct)
33
34 for i := 0; i < ct; i++ {
35 field := st.Field(i)
36 attrName := field.Tag.Get("cty")
37 if attrName != "" {
38 ret[attrName] = i
39 }
40 }
41
42 return ret
43}