27 lines
405 B
Go
27 lines
405 B
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"github.com/goccy/go-yaml"
|
|
"os"
|
|
)
|
|
|
|
func read(file string) []byte {
|
|
data, err := os.ReadFile(file)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return data
|
|
}
|
|
|
|
func parse(data []byte) yaml.MapSlice {
|
|
var result yaml.MapSlice
|
|
decoder := yaml.NewDecoder(bytes.NewReader(data),
|
|
yaml.UseOrderedMap())
|
|
err := decoder.Decode(&result)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return result
|
|
}
|