...
1
2
3 package pkg1
4
5 import (
6 "fmt"
7
8 "cuelang.org/go/cue"
9 "cuelang.org/go/encoding/gocode/gocodec"
10 _ "cuelang.org/go/pkg"
11 )
12
13 var cuegenvalMyStruct = cuegenMake("MyStruct", &MyStruct{})
14
15
16 func (x *MyStruct) Validate() error {
17 return cuegenCodec.Validate(cuegenvalMyStruct, x)
18 }
19
20
21 func (x *MyStruct) Complete() error {
22 return cuegenCodec.Complete(cuegenvalMyStruct, x)
23 }
24
25 var cuegenvalOtherStruct = cuegenMake("OtherStruct", &OtherStruct{})
26
27
28 func (x *OtherStruct) Validate() error {
29 return cuegenCodec.Validate(cuegenvalOtherStruct, x)
30 }
31
32 var cuegenvalString = cuegenMake("String", nil)
33
34
35 func (x String) ValidateCUE() error {
36 return cuegenCodec.Validate(cuegenvalString, x)
37 }
38
39 var cuegenvalSpecialString = cuegenMake("SpecialString", nil)
40
41
42 func ValidateSpecialString(x string) error {
43 return cuegenCodec.Validate(cuegenvalSpecialString, x)
44 }
45
46 var cuegenvalPtr = cuegenMake("Ptr", Ptr(nil))
47
48
49 func ValidatePtr(x Ptr) error {
50 return cuegenCodec.Validate(cuegenvalPtr, x)
51 }
52
53 var cuegenCodec, cuegenInstance_, cuegenValue = func() (*gocodec.Codec, *cue.Instance, cue.Value) {
54 var r *cue.Runtime
55 r = &cue.Runtime{}
56 instances, err := r.Unmarshal(cuegenInstanceData)
57 if err != nil {
58 panic(err)
59 }
60 if len(instances) != 1 {
61 panic("expected encoding of exactly one instance")
62 }
63 return gocodec.New(r, nil), instances[0], instances[0].Value()
64 }()
65
66
67 var cuegenInstance = cuegenInstance_
68
69
70
71 func cuegenMake(name string, x interface{}) cue.Value {
72 f, err := cuegenValue.FieldByName(name, true)
73 if err != nil {
74 panic(fmt.Errorf("could not find type %q in instance", name))
75 }
76 v := f.Value
77 if x != nil {
78 w, err := cuegenCodec.ExtractType(x)
79 if err != nil {
80 panic(err)
81 }
82 v = v.Unify(w)
83 }
84 return v
85 }
86
87
88 var cuegenInstanceData = []byte("\x01\x1f\x8b\b\x00\x00\x00\x00\x00\x00\xff\x94R\xdfo\xd3:\x18\xb5\xd3^\xe9\xd6\u06bd\x12\x7f\x00\u0487\x9fZ4\xd2\x1f\x12<D\v\xb0\x8d\x81\xf6\xb0\xb50@\b\u0103\x97|M\xad\xb9vH\x9c\xb1\n6`\x8c\xfd\xd9\vr\x9al\x85\xb7\xe5%G_r\xbes||\xfe+\x7fy\xd4+/\t-\xbf\x13\xf2\xe8[\x8b\xd25\xa9s+t\x84\u03c4\x15nL[\xb4\xfd\xca\x18K=B\xdb\x13agt\x8d\xd0\x7f\x9eK\x859-/\b!w\u02df\x1e\xa5\xff\x7f\xf8\x18\x15\xe8O\xa5\xaa\x99\x17\x84\x96\xe7\x84t\xcb\x1f-J\xff\xbd\x99\x9f\x13\xea\xd1\xf6\xbe\x98\xa3[\u052e\x86\x8c\x10r\xd5zY^\x12\x8fR\xba\x1e\x15\xa8\x84N|\x93%\xfd\xc4\xf4QG&\x96\xda\xe1\xc8\xc4\u0637\x98\xdbXX\xd1O\x8f\x92!\xa5\xf4\x8e{\xf7\x1b\xdf~T \xbd\xf2\u07a7\":\x12\t\x82\xfb\u0218\x9c\xa7&\xb3\xd0e\x1d~\x8b\xed#\xce:<\xb7\x99\xd4I\xee\xe0\\\xd8\x19g=\xc6\xf6\x16\a6+\"\x1b\xc0\x17\xd6\xd9\f\x006\xc2\xe1\x80u\xb6\x02\x80\xf0\x8cG\xc2r\xf8\n\xf7yl\x12\xce:\xe3'\x01\x8c\xed\f\xb3%\x87uv\x03p\xb6F\xfen\xe5j\x0f\xd9)<MLw=2\xf3T\xa1\xc5p\xbb\x06=\xb6Bl\xc4jC\xfe\xb6\xd1VH\x9do\xeaE\x97\xbf\xe3=\u0599\x04\u02fd\x13\x19\x1d\xb9\xad\xec\xa0\xfa5\x80\xfa\xb9\x17r\xde\xe0J\xf0X(\x19\v\x8b\xe1\xdb\x1al\xbf\xd9\u9c43\x14#)TC\x0e\xcfx\xbe\x9c\xf0%\xcb.R\f\x97.zl7\xd1&\xc3\xd73\x99W2\xe1\x19\x9f\x1a\xc3\xd9x.\xed\xb5.\x80\u0536\xe2>\xe81\xd6\xef\u00fe\xd1;'2\xb7R'\xf0Y*\x05\x87\bf.\xad\xc5\x18D\x0e\xee\xcc\b2\am\x00?\x15\xf2X(\xd4\x16^\x18p\xd2>[\xa1W\xa1l5\xa1\xd4A\xd6*\xb2\xb2\x06\x85\xc6\x13\x973\xc6Ph\x85y\x0ex\x92*\x19I\xab\x16\x80Z\x1c*\x8c}65&p6\xd9\xc4fM\xd2\xee\xbe\xfd\xbdBY\x99*\x1cO\xbb\xc3A\x8f\x9d2B\xbc\xdbTtTWt\xf4gE\xc5JAG\xd7\x05\xbdi\x1bk\xca\u0458\xd9\x18\x0e\x06+G\xfd\xeb\xfe\xc5a\u011d\xb9\xe5\xd5\a\xf0\xf8!#\xe4w\x00\x00\x00\xff\xfffX!\xc8\xe0\x03\x00\x00")
89
View as plain text