//go:embed schemas/schema.cue
var f embed.FS
configs := []cueutils.CueConfigFile{}
// Read embedded schemas
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 multiple config files
for _, configFilename := range configFilenames {
configFH, err := os.Open(configFilename)
if err != nil {
return fmt.Errorf("failed to open '%s': %w", configFilename, err)
}
defer configFH.Close()
configs = append(configs, cueutils.CueConfigFile{Data: configFH, Name: configFilename})
}
// Unmarshal into local data structure
d := MyDataStructe{}
err = cueutils.Unmarshal(configs, &d)
if err != nil {
return fmt.Errorf("failed to unmarshal: %w", err)
}
cueutils
Folders and files
Name | Name | Last commit date | ||
---|---|---|---|---|
parent directory.. | ||||