Documentation ¶
Overview ¶
Package dgocty contains the two function necessary to convert a dgo.Value into a cty.Value and vice versa.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromCty ¶
FromCty converts a cty.Value into its corresponding dgo.Value
Example (Mixed) ¶
package main import ( "fmt" "github.com/lyraproj/dgo/dgocty" "github.com/zclconf/go-cty/cty" "github.com/zclconf/go-cty/cty/gocty" ) func main() { v, err := gocty.ToCtyValue(map[string]interface{}{"a": 1, "b": []interface{}{"c", 3.14, true}}, cty.Object(map[string]cty.Type{"a": cty.Number, "b": cty.Tuple([]cty.Type{cty.String, cty.Number, cty.Bool})})) if err != nil { fmt.Println(err) } else { fmt.Println(dgocty.FromCty(v)) } }
Output: {"a":1.0,"b":["c",3.14,true]}
func ToCty ¶
ToCty converts a dgo.Value into its corresponding cty.Value. dgo.Types that are not recognized will be converted to cty.Capsule values. dgo.Sensitive values will be unwrapped.
Example (List) ¶
package main import ( "fmt" "github.com/lyraproj/dgo/dgocty" "github.com/lyraproj/dgo/vf" ) func main() { v := vf.Strings("a", "b") c := dgocty.ToCty(v) fmt.Println(c.GoString()) }
Output: cty.ListVal([]cty.Value{cty.StringVal("a"), cty.StringVal("b")})
Example (Map) ¶
package main import ( "fmt" "github.com/lyraproj/dgo/dgocty" "github.com/lyraproj/dgo/vf" ) func main() { v := vf.Map("a", 1, "b", 2) c := dgocty.ToCty(v) fmt.Println(c.GoString()) }
Output: cty.MapVal(map[string]cty.Value{"a":cty.NumberIntVal(1), "b":cty.NumberIntVal(2)})
Example (Mixed) ¶
package main import ( "fmt" "github.com/lyraproj/dgo/dgocty" "github.com/lyraproj/dgo/vf" ) func main() { v := vf.Map("a", 1, "b", vf.Values("c", 3.14, true)) c := dgocty.ToCty(v) fmt.Println(c.GoString()) }
Output: cty.ObjectVal(map[string]cty.Value{"a":cty.NumberIntVal(1), "b":cty.TupleVal([]cty.Value{cty.StringVal("c"), cty.NumberFloatVal(3.14), cty.True})})
Example (Nil) ¶
package main import ( "fmt" "github.com/lyraproj/dgo/dgocty" "github.com/lyraproj/dgo/vf" ) func main() { fmt.Println(dgocty.ToCty(vf.Nil).GoString()) }
Output: cty.NullVal(cty.DynamicPseudoType)
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.