Documentation ¶
Overview ¶
Example ¶
// Package cue provides a set of functions for loading and manipulating CUE. package main import ( "fmt" "cuelang.org/go/cue" "cuelang.org/go/cue/cuecontext" ) var src = ` { a: { b: 1 c: 2 } d: [ { e: 3 } ] } ` func main() { ctx := cuecontext.New() v, err := Compile(ctx, []byte(src)) if err != nil { panic(err) } if err := Validate(v, cue.Concrete(true)); err != nil { panic(err) } // Replace a.b with 2 v, err = Replace(ctx, v, "a.b", ctx.CompileString("2")) fmt.Printf("a.b: %v\n", v.LookupPath(cue.ParsePath("a.b"))) // Replace d[0].e with 4 v, err = Replace(ctx, v, "d[0].e", ctx.CompileString("4")) fmt.Printf("d[0].e: %v\n", v.LookupPath(cue.ParsePath("d[0].e"))) // Delete a.c v, err = Delete(ctx, v, "a.c") fmt.Printf("a: %v\n", v.LookupPath(cue.ParsePath("a"))) }
Output: a.b: 2 d[0].e: 4 a: { b: 2 }
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compile ¶
Compile compiles the given CUE contents and returns the resulting value. If the contents are invalid, an error is returned.
func Delete ¶
delete deletes the field at the given path from the given value. The path must point to either a struct field or a list index.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.