//go:embed schemas/schema.cue
var f embed.FS
configs := []cueutils.CueConfigFile{}
// Read embedded schemas or explicit config files
schemaFilename := "schemas/schema.cue"
schemaFH, err := f.Open(schemaFilename)
if err != nil {
return fmt.Errorf("failed to open '%s': %w", schemaFilename, err)
}
defer schemaFH.Close()
configs = append(configs, cueutils.CueConfigFile{Data: schemaFH, Name: schemaFilename})
// Read all cue files from a given dir
dir := "config"
// Filter to a given package name or set to _ for files without a package
packageName := "myPackage"
// Provide a pointer receiver for evaluated data for mostly debugging purposes
value := cueutils.NewValue()
// Unmarshal into local data structure
d := MyDataStructure{}
err = cueutils.Unmarshal(configs, dir, packageName, value, &d)
if err != nil {
return fmt.Errorf("failed to unmarshal: %w", err)
}
Files
cueutils
Folders and files
Name | Name | Last commit date | ||
---|---|---|---|---|
parent directory.. | ||||