File: type_string_test.go

package info (click to toggle)
golang-github-zclconf-go-cty-debug 0.0~git20191215.b22d67c-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 108 kB
  • sloc: makefile: 2
file content (44 lines) | stat: -rw-r--r-- 1,147 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package ctydebug_test

import (
	"fmt"

	"github.com/zclconf/go-cty-debug/ctydebug"
	"github.com/zclconf/go-cty/cty"
)

func ExampleTypeString() {
	ty := cty.Object(map[string]cty.Type{
		"source_account":  cty.String,
		"fee":             cty.Number,
		"sequence_number": cty.Number,
		"time_bounds":     cty.Tuple([]cty.Type{cty.String, cty.String}),
		"memo":            cty.DynamicPseudoType,
		"payments": cty.List(cty.Object(map[string]cty.Type{
			"destination_account": cty.String,
			"asset":               cty.String,
			"amount":              cty.Number,
		})),
	})

	fmt.Print(ctydebug.TypeString(ty))

	// Output:
	// cty.Object(map[string]cty.Type{
	//     "fee": cty.Number,
	//     "memo": cty.DynamicPseudoType,
	//     "payments": cty.List(
	//         cty.Object(map[string]cty.Type{
	//             "amount": cty.Number,
	//             "asset": cty.String,
	//             "destination_account": cty.String,
	//         }),
	//     ),
	//     "sequence_number": cty.Number,
	//     "source_account": cty.String,
	//     "time_bounds": cty.Tuple([]cty.Type{
	//         cty.String,
	//         cty.String,
	//     }),
	// })
}