From e52aee5b52fceb0570ec7ac7653f71a0da010864 Mon Sep 17 00:00:00 2001 From: Fatih Arslan Date: Thu, 16 Feb 2023 12:18:28 +0300 Subject: [PATCH 1/2] Update CI dependencies --- .github/workflows/go.yml | 43 ++++++++++++++++++++++++++++++---------- go.mod | 2 +- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index efd782f..72474f6 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,25 +1,48 @@ name: build -on: [push, pull_request] -jobs: +on: + push: + branches: + - main + pull_request: +jobs: test-build: name: Test & Build runs-on: ubuntu-latest steps: - - name: Set up Go 1.13 - uses: actions/setup-go@v1 + - name: Set up Go + uses: actions/setup-go@v3 with: - go-version: 1.13 - id: go + go-version: '>=1.20.0' - name: Check out code into the Go module directory - uses: actions/checkout@v1 + uses: actions/checkout@v3 + + - name: Run go mod tidy + run: | + set -e + go mod tidy + output=$(git status -s) + if [ -z "${output}" ]; then + exit 0 + fi + echo 'We wish to maintain a tidy state for go mod. Please run `go mod tidy` on your branch, commit and push again.' + echo 'Running `go mod tidy` on this CI test yields with the following changes:' + echo "$output" + exit 1 - name: Test - run: | - go mod tidy -v - go test -race ./... + run: go test -race ./... + + - name: Lint + run: "go vet ./..." + + - name: Staticcheck + uses: dominikh/staticcheck-action@v1.2.0 + with: + version: "2023.1.1" + install-go: false - name: Build run: go build ./... diff --git a/go.mod b/go.mod index 61b2f67..6a2fa1e 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/fatih/motion -go 1.12 +go 1.20 From 1d25e7a2af7913ee747f0abcef082bc657bba67c Mon Sep 17 00:00:00 2001 From: Fatih Arslan Date: Thu, 16 Feb 2023 12:23:19 +0300 Subject: [PATCH 2/2] Fix error style --- main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 03a4ba4..2f81e44 100644 --- a/main.go +++ b/main.go @@ -14,7 +14,7 @@ import ( func main() { if err := realMain(); err != nil { - fmt.Fprint(os.Stderr, err.Error()) + fmt.Fprintf(os.Stderr, "%s\n", err.Error()) os.Exit(1) } } @@ -83,17 +83,17 @@ func realMain() error { case "json": b, err := json.MarshalIndent(&res, "", "\t") if err != nil { - return fmt.Errorf("JSON error: %s\n", err) + return fmt.Errorf("JSON error: %s", err) } os.Stdout.Write(b) case "vim": b, err := vim.Marshal(&res) if err != nil { - return fmt.Errorf("VIM error: %s\n", err) + return fmt.Errorf("VIM error: %s", err) } os.Stdout.Write(b) default: - return fmt.Errorf("wrong -format value: %q.\n", *flagFormat) + return fmt.Errorf("wrong -format value: %q", *flagFormat) } return nil