From d8f13a84a77b98819a94de81d7ad871c38c21922 Mon Sep 17 00:00:00 2001 From: zongz Date: Fri, 6 Sep 2024 16:44:49 +0800 Subject: [PATCH] fix: fix nil pointer Signed-off-by: zongz --- pkg/client/update.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/client/update.go b/pkg/client/update.go index 9414e992..773d4c72 100644 --- a/pkg/client/update.go +++ b/pkg/client/update.go @@ -4,6 +4,7 @@ import ( "fmt" "path/filepath" + orderedmap "github.com/elliotchance/orderedmap/v2" "kcl-lang.io/kpm/pkg/downloader" pkg "kcl-lang.io/kpm/pkg/package" ) @@ -40,11 +41,11 @@ func (c *KpmClient) Update(options ...UpdateOption) (*pkg.KclPkg, error) { modDeps := kpkg.ModFile.Dependencies.Deps if modDeps == nil { - return nil, fmt.Errorf("kcl.mod dependencies is nil") + return kpkg, nil } lockDeps := kpkg.Dependencies.Deps if lockDeps == nil { - return nil, fmt.Errorf("kcl.mod.lock dependencies is nil") + lockDeps = orderedmap.NewOrderedMap[string, pkg.Dependency]() } // Create a new dependency resolver