mirror of
https://github.com/vsariola/sointu.git
synced 2025-06-04 01:28:45 -04:00
refactor(tracker): use UnmarshalStrict when decoding embedded yamls
Since we have 100% control over what data gets embedded, there is no reason to embed anything that doesn't pass the strict yaml parsing and it's better we throw a panic right away so it's easy to catch this during development.
This commit is contained in:
parent
27bf8220c0
commit
ddbaf6a4bb
@ -41,7 +41,7 @@ var defaultKeyBindingsYaml []byte
|
|||||||
|
|
||||||
func loadDefaultKeyBindings() []KeyBinding {
|
func loadDefaultKeyBindings() []KeyBinding {
|
||||||
var keyBindings []KeyBinding
|
var keyBindings []KeyBinding
|
||||||
err := yaml.Unmarshal(defaultKeyBindingsYaml, &keyBindings)
|
err := yaml.UnmarshalStrict(defaultKeyBindingsYaml, &keyBindings)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Errorf("failed to unmarshal keybindings: %w", err))
|
panic(fmt.Errorf("failed to unmarshal keybindings: %w", err))
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ var defaultPreferencesYaml []byte
|
|||||||
|
|
||||||
func loadDefaultPreferences() Preferences {
|
func loadDefaultPreferences() Preferences {
|
||||||
var preferences Preferences
|
var preferences Preferences
|
||||||
err := yaml.Unmarshal(defaultPreferencesYaml, &preferences)
|
err := yaml.UnmarshalStrict(defaultPreferencesYaml, &preferences)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Errorf("failed to unmarshal preferences: %w", err))
|
panic(fmt.Errorf("failed to unmarshal preferences: %w", err))
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
|
|
||||||
"github.com/vsariola/sointu"
|
"github.com/vsariola/sointu"
|
||||||
"github.com/vsariola/sointu/vm"
|
"github.com/vsariola/sointu/vm"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:generate go run generate/main.go
|
//go:generate go run generate/main.go
|
||||||
@ -180,7 +180,7 @@ func init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
var instr sointu.Instrument
|
var instr sointu.Instrument
|
||||||
if yaml.Unmarshal(data, &instr) == nil {
|
if yaml.UnmarshalStrict(data, &instr) == nil {
|
||||||
noExt := path[:len(path)-len(filepath.Ext(path))]
|
noExt := path[:len(path)-len(filepath.Ext(path))]
|
||||||
splitted := splitPath(noExt)
|
splitted := splitPath(noExt)
|
||||||
splitted = splitted[1:] // remove "presets" from the path
|
splitted = splitted[1:] // remove "presets" from the path
|
||||||
|
Loading…
x
Reference in New Issue
Block a user