github.com/solo-io/cue@v0.4.7/encoding/gocode/testdata/pkg1/cue_gen.go (about) 1 // Code generated by gocode.Generate; DO NOT EDIT. 2 3 package pkg1 4 5 import ( 6 "fmt" 7 8 "github.com/solo-io/cue/cue" 9 "github.com/solo-io/cue/encoding/gocode/gocodec" 10 _ "github.com/solo-io/cue/pkg" 11 ) 12 13 var cuegenvalMyStruct = cuegenMake("MyStruct", &MyStruct{}) 14 15 // Validate validates x. 16 func (x *MyStruct) Validate() error { 17 return cuegenCodec.Validate(cuegenvalMyStruct, x) 18 } 19 20 // Complete completes x. 21 func (x *MyStruct) Complete() error { 22 return cuegenCodec.Complete(cuegenvalMyStruct, x) 23 } 24 25 var cuegenvalOtherStruct = cuegenMake("OtherStruct", &OtherStruct{}) 26 27 // Validate validates x. 28 func (x *OtherStruct) Validate() error { 29 return cuegenCodec.Validate(cuegenvalOtherStruct, x) 30 } 31 32 var cuegenvalString = cuegenMake("String", nil) 33 34 // ValidateCUE validates x. 35 func (x String) ValidateCUE() error { 36 return cuegenCodec.Validate(cuegenvalString, x) 37 } 38 39 var cuegenvalSpecialString = cuegenMake("SpecialString", nil) 40 41 // ValidateSpecialString validates x. 42 func ValidateSpecialString(x string) error { 43 return cuegenCodec.Validate(cuegenvalSpecialString, x) 44 } 45 46 var cuegenvalPtr = cuegenMake("Ptr", Ptr(nil)) 47 48 // ValidatePtr validates x. 49 func ValidatePtr(x Ptr) error { 50 return cuegenCodec.Validate(cuegenvalPtr, x) 51 } 52 53 var cuegenCodec, cuegenInstance = func() (*gocodec.Codec, *cue.Instance) { 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] 64 }() 65 66 // cuegenMake is called in the init phase to initialize CUE values for 67 // validation functions. 68 func cuegenMake(name string, x interface{}) cue.Value { 69 f, err := cuegenInstance.Value().FieldByName(name, true) 70 if err != nil { 71 panic(fmt.Errorf("could not find type %q in instance", name)) 72 } 73 v := f.Value 74 if x != nil { 75 w, err := cuegenCodec.ExtractType(x) 76 if err != nil { 77 panic(err) 78 } 79 v = v.Unify(w) 80 } 81 return v 82 } 83 84 // Data size: 601 bytes. 85 var cuegenInstanceData = []byte("\x01\x1f\x8b\b\x00\x00\x00\x00\x00\x00\xff\x94R\xdfo\xd3:\x18\xb5\xd3^\xe9\xd6\u06bd\x12\u007f\x00\u0487\x9fZ4\xd2\x1f\x12B\x8a\x16`\x1b\x03\xedaka\x80\x10\x88\a/\xf9\x9aZs\xed\x908c\x15l\x120\xc6\xfe\xea\x059M\xb6\xc2\xdb\xf2\x92\xa3/9\xdf9>>\xff\x95\xbf<\ua557\x84\x96\xdf\tyT~kQ\xba&un\x85\x8e\xf0\x99\xb0\xc2\xcdi\x8b\xb6_\x19c\xa9Gh{\"\uc32e\x11\xfa\xcfs\xa90\xa7\xe5\x05!\xe4n\xf9\u04e3\xf4\xff\x0f\x1f\xa3\x02\xfd\xa9T5\xf3\x82\xd0\xf2\x9c\x90n\xf9\xa3E\xe9\xbf7\xf3sB=\xda\xde\x17st\x8b\xda\u0550\x11B\xaeZ/\xcbK\xe2QJ\u05e3\x02\x95\u0409o\xb2\xa4\x9f\x98>\xea\xc8\xc4R;\x1c\x99\x18\xfb\x16s\x1b\v+\xfa\xe9Q2\xa4\x94\xdeq\xef~\xe3\u06cf\n\xa4W\xde\xfbTDG\"Ap\x1f\x19\x93\xf3\xd4d\x16\xba\xac\xc3o\xb1}\xc4Y\x87\xe76\x93:\xc9\x1d\x9c\v;\xe3\xac\xc7\xd8\xde\xe2\xc0fEd\x03\xf8\xc2:\x9b\x01\xc0F8\x1c\xb0\xceV\x00\x10\x9e\xf1HX\x0e_\xe1>\x8fM\xc2Yg\xfc$\x80\xb1\x9da\xb6\xe4\xb0\xcen\x00\xce\xd6\xc8\u07ed\\\xed!;\x85\xa7\x89\xe9\xaeGf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