diff --git a/agent/pkg/agent/config.go b/agent/pkg/agent/config.go index 404554e4..2d18353d 100644 --- a/agent/pkg/agent/config.go +++ b/agent/pkg/agent/config.go @@ -4,6 +4,7 @@ import ( "context" "crypto/tls" "crypto/x509" + "encoding/json" "encoding/pem" "errors" "fmt" @@ -15,7 +16,6 @@ import ( "strings" "time" - "github.com/bytedance/sonic" "github.com/rs/zerolog" "github.com/rs/zerolog/log" "github.com/yusing/godoxy/agent/pkg/agent/common" @@ -366,7 +366,7 @@ func (cfg *AgentConfig) fetchJSON(ctx context.Context, endpoint string, out any) return resp.StatusCode, nil } - err = sonic.Unmarshal(data, out) + err = json.Unmarshal(data, out) if err != nil { return 0, err } diff --git a/goutils b/goutils index bcc4b498..e5fba769 160000 --- a/goutils +++ b/goutils @@ -1 +1 @@ -Subproject commit bcc4b498f87881bfa2ddd7873a49211c76f3ec03 +Subproject commit e5fba76994e449570fe8a9221226d03cfeaf1c45 diff --git a/internal/homepage/icons/list/list_icons.go b/internal/homepage/icons/list/list_icons.go index 968fd3a6..b9e097a0 100644 --- a/internal/homepage/icons/list/list_icons.go +++ b/internal/homepage/icons/list/list_icons.go @@ -55,20 +55,20 @@ func init() { func InitCache() { m := make(IconMap) - err := serialization.LoadFileIfExist(common.IconListCachePath, &m, sonic.Unmarshal) + err := serialization.LoadFileIfExist(common.IconListCachePath, &m, json.Unmarshal) if err != nil { // backward compatible oldFormat := struct { Icons IconMap LastUpdate time.Time }{} - err = serialization.LoadFileIfExist(common.IconListCachePath, &oldFormat, sonic.Unmarshal) + err = serialization.LoadFileIfExist(common.IconListCachePath, &oldFormat, json.Unmarshal) if err != nil { log.Error().Err(err).Msg("failed to load icons") } else { m = oldFormat.Icons // store it to disk immediately - _ = serialization.SaveFile(common.IconListCachePath, &m, 0o644, sonic.Marshal) + _ = serialization.SaveFile(common.IconListCachePath, &m, 0o644, json.Marshal) } } else if len(m) > 0 { log.Info(). @@ -84,7 +84,7 @@ func InitCache() { task.OnProgramExit("save_icons_cache", func() { icons := iconsCache.Load() - _ = serialization.SaveFile(common.IconListCachePath, &icons, 0o644, sonic.Marshal) + _ = serialization.SaveFile(common.IconListCachePath, &icons, 0o644, json.Marshal) }) go backgroundUpdateIcons() @@ -105,7 +105,7 @@ func backgroundUpdateIcons() { // swap old cache with new cache iconsCache.Store(newCache) // save it to disk - err := serialization.SaveFile(common.IconListCachePath, &newCache, 0o644, sonic.Marshal) + err := serialization.SaveFile(common.IconListCachePath, &newCache, 0o644, json.Marshal) if err != nil { log.Warn().Err(err).Msg("failed to save icons") } diff --git a/internal/jsonstore/jsonstore.go b/internal/jsonstore/jsonstore.go index 79043377..8a42a389 100644 --- a/internal/jsonstore/jsonstore.go +++ b/internal/jsonstore/jsonstore.go @@ -83,7 +83,7 @@ func save() error { errs := gperr.NewBuilder("failed to save data stores") for ns, store := range stores { path := filepath.Join(storesPath, string(ns)+".json") - if err := serialization.SaveFile(path, &store, 0o644, sonic.Marshal); err != nil { + if err := serialization.SaveFile(path, &store, 0o644, json.Marshal); err != nil { errs.Add(err) } }