From d1a83a95dcedc63fd0dfcc65b300ca134e8fe388 Mon Sep 17 00:00:00 2001 From: Xiao Cui Date: Thu, 27 Jun 2024 22:06:38 -0400 Subject: [PATCH] Add lint workflow --- .github/workflows/lint.yml | 39 ++++++++++++++++++++++++++++++++++++++ main.go | 6 +++--- 2 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..bb478e1 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,39 @@ +name: Lint +on: + push: + paths: + - "**.go" + - go.mod + - go.sum + pull_request: + paths: + - "**.go" + - go.mod + - go.sum + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - name: Set up Go 1.19 + uses: actions/setup-go@v3 + with: + go-version: 1.19 + + - name: Check out code + uses: actions/checkout@v2 + + - name: Verify dependencies + env: + LINT_VERSION: 1.50.1 + run: | + go mod verify + go mod download + + curl -fsSL https://github.com/golangci/golangci-lint/releases/download/v${LINT_VERSION}/golangci-lint-${LINT_VERSION}-linux-amd64.tar.gz | \ + tar xz --strip-components 1 --wildcards \*/golangci-lint + mkdir -p bin && mv golangci-lint bin/ + + - name: Run checks + run: bin/golangci-lint run --out-format=github-actions diff --git a/main.go b/main.go index 45bb94d..0f555c4 100644 --- a/main.go +++ b/main.go @@ -35,12 +35,12 @@ func mainRun() exitCode { rootCmd, err := cmd.NewRootCmd(iostream) if err != nil { - fmt.Fprint(stderr, "failed to create root command: %s\n", err) + fmt.Fprintf(stderr, "failed to create root command: %s\n", err) return exitError } - if _, err := rootCmd.ExecuteContextC(ctx); err != nil { + if command, err := rootCmd.ExecuteContextC(ctx); err != nil { // printError(stderr, err, cmd, hasDebug) - // fmt.Fprint(stderr, "Error %s", err, command) + fmt.Fprintf(stderr, "Error %v", command) } return exitOK