From 4d443e9cc3812bdda20b9698ba671031765711e8 Mon Sep 17 00:00:00 2001 From: momo <1012651275@qq.com> Date: Fri, 1 Sep 2023 11:38:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BC=98=E5=8C=96=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E7=BC=A9=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/repositories/resource.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/service/repositories/resource.go b/service/repositories/resource.go index d6eb0aca..5384ad66 100644 --- a/service/repositories/resource.go +++ b/service/repositories/resource.go @@ -61,7 +61,7 @@ func (d *defaultResource) UpdateMetadata(ctx context.Context, in *UpdateMetadata return err } var newResourceMetadata string - if oldResource.Metadata != nil && *oldResource.Metadata != "{}" { + if oldResource.Metadata != nil && *oldResource.Metadata != "{}" && *oldResource.Metadata != "" { var oldResourceMetadata map[string]interface{} err = json.Unmarshal([]byte(*oldResource.Metadata), &oldResourceMetadata) if err != nil { @@ -72,8 +72,8 @@ func (d *defaultResource) UpdateMetadata(ctx context.Context, in *UpdateMetadata switch val := v.(type) { case map[string]interface{}: oldResourceMetadataData := oldResourceMetadata[k].(map[string]interface{}) - for key := range val { - oldResourceMetadataData[key] = val + for key, val1 := range val { + oldResourceMetadataData[key] = val1 } oldResourceMetadata[k] = oldResourceMetadataData } @@ -90,8 +90,8 @@ func (d *defaultResource) UpdateMetadata(ctx context.Context, in *UpdateMetadata switch val := v.(type) { case map[string]interface{}: var resourceMetadataData = make(map[string]interface{}, len(val)) - for key := range val { - resourceMetadataData[key] = val + for key, val1 := range val { + resourceMetadataData[key] = val1 } resourceMetadata[k] = resourceMetadataData }