mirror of
https://github.com/vsariola/sointu.git
synced 2025-11-12 12:52:53 -05:00
refactor: use yaml.v3 everywhere and remove dependency on yaml.v2
This commit is contained in:
parent
f4bb2bc754
commit
8e99c93d14
@ -1,12 +1,13 @@
|
||||
package gioui
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
"gioui.org/unit"
|
||||
)
|
||||
@ -53,7 +54,9 @@ func ReadCustomConfig(filename string, target any) error {
|
||||
// return at least the default config, and the warning will just tell if there
|
||||
// was a problem parsing the custom config.
|
||||
func ReadConfig(defaultConfig []byte, path string, target any) (warn error) {
|
||||
if err := yaml.UnmarshalStrict(defaultConfig, target); err != nil {
|
||||
dec := yaml.NewDecoder(bytes.NewReader(defaultConfig))
|
||||
dec.KnownFields(true)
|
||||
if err := dec.Decode(target); err != nil {
|
||||
panic(fmt.Errorf("ReadConfig %v failed to unmarshal the embedded default config: %w", path, err))
|
||||
}
|
||||
return ReadCustomConfig(path, target)
|
||||
|
||||
Reference in New Issue
Block a user