Skip to content

Instantly share code, notes, and snippets.

@erkanzileli
Created September 8, 2021 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erkanzileli/a789e362073497670230763269cecbad to your computer and use it in GitHub Desktop.
Save erkanzileli/a789e362073497670230763269cecbad to your computer and use it in GitHub Desktop.
sample cue usage
package main
import (
"cuelang.org/go/cue"
"cuelang.org/go/cue/cuecontext"
cuejson "cuelang.org/go/encoding/json"
"io/ioutil"
)
func main() {
ctx := cuecontext.New()
cueBs, _ := ioutil.ReadFile("policy.cue")
v := ctx.CompileString(string(cueBs), []cue.BuildOption{}...)
input := `
{
"foo": {
"bar": {
"baz": 10
"taz": 1
}
}
}`
err := cuejson.Validate([]byte(input), v)
if err != nil {
panic(err)
}
}
foo: bar: {
baz: <11
taz: string
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment