support notes for config

This commit is contained in:
yuzuki999 committed 2023-08-20 22:24:57 +08:00
1 parent 0fce6588da
commit c3bb809c71
5 files changed
+170 -35

No files matched your search

+2 -1
View File
@@ -2,6 +2,7 @@ package conf
import (
"fmt"
"github.com/InazumaV/V2bX/common/json5"
"os"
"github.com/goccy/go-json"
@@ -28,5 +29,5 @@ func (p *Conf) LoadFromPath(filePath string) error {
return fmt.Errorf("open config file error: %s", err)
}
defer f.Close()
return json.NewDecoder(f).Decode(p)
return json.NewDecoder(json5.NewTrimNodeReader(f)).Decode(p)
}
+1 -1
View File
@@ -6,7 +6,7 @@ import (
func TestConf_LoadFromPath(t *testing.T) {
c := New()
t.Log(c.LoadFromPath("./config.json"), c.NodeConfig)
t.Log(c.LoadFromPath("../example/config.json"), c.NodeConfig)
}
func TestConf_Watch(t *testing.T) {