From d6afc00c9dce7ff2146db705ecf412e340187e71 Mon Sep 17 00:00:00 2001 From: Leo Date: Fri, 27 Sep 2024 16:28:43 +0000 Subject: [PATCH] fix(sdk.go): refactor GetLocalSdkPackage to improve version handling and simplify directory processing logic --- internal/sdk.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/internal/sdk.go b/internal/sdk.go index 6d32c086..a5460337 100644 --- a/internal/sdk.go +++ b/internal/sdk.go @@ -581,17 +581,17 @@ func (b *Sdk) GetLocalSdkPackage(version Version) (*Package, error) { } for _, d := range dir { if d.IsDir() { - split := strings.SplitN(d.Name(), "-", 2) - if len(split) != 2 { - continue - } - name := split[0] - v := split[1] - logger.Debugf("Load SDK package item: name:%s, version: %s \n", name, v) - items[name] = &Info{ - Name: name, - Version: Version(v), - Path: filepath.Join(versionPath, d.Name()), + if strings.HasSuffix(d.Name(), string(version)) { + name := strings.TrimSuffix(d.Name(), "-"+string(version)) + if name == "" { + continue + } + logger.Debugf("Load SDK package item: name:%s, version: %s \n", name, version) + items[name] = &Info{ + Name: name, + Version: Version(version), + Path: filepath.Join(versionPath, d.Name()), + } } } }