mirror of
https://github.com/InazumaV/Ratte.git
synced 2026-02-04 12:40:12 +00:00
update
update: deps fix: sig waiting fix: watcher fix: nil pointer panic
This commit is contained in:
@@ -43,7 +43,7 @@ func New(path string) *Conf {
|
||||
}
|
||||
|
||||
func (c *Conf) Load(data []byte) error {
|
||||
if len(data) >= 0 {
|
||||
if len(data) > 0 {
|
||||
err := json.Unmarshal(data, c)
|
||||
if err != nil {
|
||||
return fmt.Errorf("decode json error: %w", err)
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package conf
|
||||
|
||||
import "github.com/goccy/go-json"
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/goccy/go-json"
|
||||
)
|
||||
|
||||
type Core struct {
|
||||
Name string `json:"Name,omitempty"`
|
||||
@@ -13,7 +16,7 @@ type _core Core
|
||||
func (c *Core) UnmarshalJSON(data []byte) error {
|
||||
err := json.Unmarshal(data, (*_core)(c))
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("failed to unmarshal core: %v", err)
|
||||
}
|
||||
if len(c.Config) == 0 {
|
||||
c.Config = data
|
||||
|
||||
16
conf/node.go
16
conf/node.go
@@ -68,7 +68,7 @@ func (b *IntBytes) UnmarshalJSON(data []byte) error {
|
||||
var numS string
|
||||
err = json.Unmarshal(data, &numS)
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("failed to unmarshal intBytes: %v", err)
|
||||
}
|
||||
unit := numS[len(numS)-2:]
|
||||
num, err = strconv.ParseUint(numS[:len(numS)-2], 10, 64)
|
||||
@@ -102,7 +102,7 @@ func (n *Node) UnmarshalJSON(data []byte) (err error) {
|
||||
rn := rawNodeConfig{}
|
||||
err = json.Unmarshal(data, &rn)
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("failed to unmarshal Node: %v", err)
|
||||
}
|
||||
|
||||
n.Remote = Remote{
|
||||
@@ -112,24 +112,24 @@ func (n *Node) UnmarshalJSON(data []byte) (err error) {
|
||||
if len(rn.RemoteRaw) > 0 {
|
||||
err = json.Unmarshal(rn.RemoteRaw, &n.Remote)
|
||||
if err != nil {
|
||||
return
|
||||
return fmt.Errorf("failed to unmarshal RemoteRaw: %v", err)
|
||||
}
|
||||
} else {
|
||||
err = json.Unmarshal(data, &n.Remote)
|
||||
if err != nil {
|
||||
return
|
||||
return fmt.Errorf("failed to unmarshal Remote: %v", err)
|
||||
}
|
||||
}
|
||||
n.Options = Options{}
|
||||
if len(rn.OptRaw) > 0 {
|
||||
err = json.Unmarshal(rn.OptRaw, &n.Options)
|
||||
if err != nil {
|
||||
return
|
||||
return fmt.Errorf("failed to unmarshal OptRaw: %v", err)
|
||||
}
|
||||
} else {
|
||||
err = json.Unmarshal(data, &n.Options)
|
||||
if err != nil {
|
||||
return
|
||||
return fmt.Errorf("failed to unmarshal Options: %v", err)
|
||||
}
|
||||
}
|
||||
n.Trigger = Trigger{
|
||||
@@ -141,12 +141,12 @@ func (n *Node) UnmarshalJSON(data []byte) (err error) {
|
||||
if len(rn.TriggerRaw) > 0 {
|
||||
err = json.Unmarshal(rn.OptRaw, &n.Trigger)
|
||||
if err != nil {
|
||||
return
|
||||
return fmt.Errorf("failed to unmarshal TriggerRaw: %v", err)
|
||||
}
|
||||
} else {
|
||||
err = json.Unmarshal(data, &n.Trigger)
|
||||
if err != nil {
|
||||
return
|
||||
return fmt.Errorf("failed to unmarshal Trigger: %v", err)
|
||||
}
|
||||
}
|
||||
if len(rn.Name) > 0 {
|
||||
|
||||
@@ -46,7 +46,7 @@ func (c *Conf) Watch() error {
|
||||
c.configWatcher = w
|
||||
}
|
||||
} else {
|
||||
if !c.Watcher.WatchLocalConfig {
|
||||
if c.Watcher.WatchLocalConfig {
|
||||
w := watcher.NewLocalWatcher(path.Dir(c.path), []string{path.Base(c.path)})
|
||||
c.configWatcher = w
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user