From 943f2f3f73c57417fc937b4e516c59e0778daaa4 Mon Sep 17 00:00:00 2001 From: Renzheng Wang Date: Thu, 9 May 2024 07:26:47 +0800 Subject: [PATCH] remove dependency for slices package (#85) * remove dependency for slices package * update golang build env version --- .github/workflows/release.yml | 2 +- cmd/api.go | 12 ++++++++++-- go.mod | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 342a881bd5..7dcba83bfe 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ jobs: - name: Set up go uses: actions/setup-go@v3 with: - go-version: 1.20.14 + go-version: 1.19.2 - name: Build run: bash hack/github-release.sh diff --git a/cmd/api.go b/cmd/api.go index 6386ff51c5..10441ad347 100644 --- a/cmd/api.go +++ b/cmd/api.go @@ -6,7 +6,6 @@ import ( "fmt" "io" "io/ioutil" - "slices" "strconv" "strings" "sync" @@ -50,7 +49,7 @@ func NewCmdAPI(out io.Writer) *cobra.Command { Short: "Call API", Long: "Call API", Run: func(c *cobra.Command, args []string) { - if slices.Contains(args, "--help") { + if containHelp(args) { fmt.Fprintln(out, HelpInfo) return } @@ -251,3 +250,12 @@ func genericInvokeRepeatWrapper(repeatsConfig *RepeatsConfig, params map[string] refresh.Do(fmt.Sprintf("finally, total:%d, success:%d, fail:%d", repeats, success.Load(), repeats-int(success.Load()))) return nil } + +func containHelp(args []string) bool { + for _, arg := range args { + if arg == "--help" { + return true + } + } + return false +} diff --git a/go.mod b/go.mod index 2491b41754..95fd05f6c6 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/ucloud/ucloud-cli -go 1.20 +go 1.19 require ( github.com/fatih/color v1.13.0