Skip to content

how to disable cue instance validation in go api? #2296

Answered by verdverm
sahroshan asked this question in Q&A
Discussion options

You must be logged in to vote

You want to use the cue/load package

https://cuetorials.com/go-api/loading/

package main

import (
	"fmt"

	"cuelang.org/go/cue/cuecontext"
	"cuelang.org/go/cue/load"
)

func main() {
	// We need a cue.Context for building after loading
	ctx := cuecontext.New()

	// The entrypoints are the same as the files you'd specify at the command line
	entrypoints := []string{"hello.cue"}

	// Load Cue files into Cue build.Instances slice
	// the second arg is a configuration object, we'll see this later
	bis := load.Instances(entrypoints, nil)

	// Loop over the instances, typically there is only one
	for _, bi := range bis {
		// check for errors on the instance
		// these are typically parsing er…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@sahroshan
Comment options

@sahroshan
Comment options

Answer selected by sahroshan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants