mirror of
https://github.com/vsariola/sointu.git
synced 2025-11-12 21:02:52 -05:00
refactor: use yaml.v3 everywhere and remove dependency on yaml.v2
This commit is contained in:
parent
f4bb2bc754
commit
8e99c93d14
3
go.mod
3
go.mod
@ -12,8 +12,7 @@ require (
|
|||||||
github.com/viterin/vek v0.4.2
|
github.com/viterin/vek v0.4.2
|
||||||
gitlab.com/gomidi/midi/v2 v2.2.10
|
gitlab.com/gomidi/midi/v2 v2.2.10
|
||||||
golang.org/x/exp/shiny v0.0.0-20250408133849-7e4ce0ab07d0
|
golang.org/x/exp/shiny v0.0.0-20250408133849-7e4ce0ab07d0
|
||||||
golang.org/x/text v0.24.0
|
golang.org/x/text v0.24.0
|
||||||
gopkg.in/yaml.v2 v2.3.0
|
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
pipelined.dev/audio/vst2 v0.10.1-0.20240223162706-41e9b65fb5c2
|
pipelined.dev/audio/vst2 v0.10.1-0.20240223162706-41e9b65fb5c2
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package gioui
|
package gioui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
_ "embed"
|
_ "embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -10,7 +11,7 @@ import (
|
|||||||
"gioui.org/io/event"
|
"gioui.org/io/event"
|
||||||
"gioui.org/io/key"
|
"gioui.org/io/key"
|
||||||
"github.com/vsariola/sointu/tracker"
|
"github.com/vsariola/sointu/tracker"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@ -31,7 +32,9 @@ var defaultKeyBindings []byte
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
var keyBindings, userKeybindings []KeyBinding
|
var keyBindings, userKeybindings []KeyBinding
|
||||||
if err := yaml.UnmarshalStrict(defaultKeyBindings, &keyBindings); err != nil {
|
dec := yaml.NewDecoder(bytes.NewReader(defaultKeyBindings))
|
||||||
|
dec.KnownFields(true)
|
||||||
|
if err := dec.Decode(&keyBindings); err != nil {
|
||||||
panic(fmt.Errorf("failed to unmarshal default keybindings: %w", err))
|
panic(fmt.Errorf("failed to unmarshal default keybindings: %w", err))
|
||||||
}
|
}
|
||||||
if err := ReadCustomConfig("keybindings.yml", &userKeybindings); err == nil {
|
if err := ReadCustomConfig("keybindings.yml", &userKeybindings); err == nil {
|
||||||
|
|||||||
@ -1,12 +1,13 @@
|
|||||||
package gioui
|
package gioui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
_ "embed"
|
_ "embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v3"
|
||||||
|
|
||||||
"gioui.org/unit"
|
"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
|
// return at least the default config, and the warning will just tell if there
|
||||||
// was a problem parsing the custom config.
|
// was a problem parsing the custom config.
|
||||||
func ReadConfig(defaultConfig []byte, path string, target any) (warn error) {
|
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))
|
panic(fmt.Errorf("ReadConfig %v failed to unmarshal the embedded default config: %w", path, err))
|
||||||
}
|
}
|
||||||
return ReadCustomConfig(path, target)
|
return ReadCustomConfig(path, target)
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
"github.com/vsariola/sointu"
|
"github.com/vsariola/sointu"
|
||||||
"github.com/vsariola/sointu/vm"
|
"github.com/vsariola/sointu/vm"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package tracker
|
package tracker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"embed"
|
"embed"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
@ -12,7 +13,7 @@ import (
|
|||||||
|
|
||||||
"github.com/vsariola/sointu"
|
"github.com/vsariola/sointu"
|
||||||
"github.com/vsariola/sointu/vm"
|
"github.com/vsariola/sointu/vm"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:generate go run generate/gmdls_entries.go
|
//go:generate go run generate/gmdls_entries.go
|
||||||
@ -169,7 +170,10 @@ func (m *Presets) loadPresetsFromFs(fsys fs.FS, userDefined bool, seenDir map[st
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
var instr sointu.Instrument
|
var instr sointu.Instrument
|
||||||
if yaml.UnmarshalStrict(data, &instr) == nil {
|
|
||||||
|
dec := yaml.NewDecoder(bytes.NewReader(data))
|
||||||
|
dec.KnownFields(true)
|
||||||
|
if dec.Decode(&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
|
||||||
|
|||||||
@ -15,7 +15,7 @@ import (
|
|||||||
|
|
||||||
"github.com/vsariola/sointu"
|
"github.com/vsariola/sointu"
|
||||||
"github.com/vsariola/sointu/vm/compiler/bridge"
|
"github.com/vsariola/sointu/vm/compiler/bridge"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v3"
|
||||||
// TODO: test the song using a mocks instead
|
// TODO: test the song using a mocks instead
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ import (
|
|||||||
|
|
||||||
"github.com/vsariola/sointu"
|
"github.com/vsariola/sointu"
|
||||||
"github.com/vsariola/sointu/vm"
|
"github.com/vsariola/sointu/vm"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
const errorThreshold = 1e-2
|
const errorThreshold = 1e-2
|
||||||
|
|||||||
Reference in New Issue
Block a user