From 624992ad7bf27d2ec6909bb9e420a51007452f17 Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Sun, 16 Oct 2022 08:54:34 -0700 Subject: [PATCH] Add staticcheck and go-generate Github check (#968) * Fix Staticcheck errors & minor logic simplification Simplify logic in ui.go. In that diff, `st` would already have the Reversed flag set; there's no need to set it again. Also, minor changes to remove all the statickcheck errors VS code's Go extension complains about. * Add staticcheck and Go 1.19 go-generate Github check This adds a few Github action checks: 1. Check that `go fmt` and `go generate` were run on Go 1.19, following up on https://github.com/gokcehan/lf/commit/654b8737b8a35729aa89aa93acf05ed5871b2616. On earlier Go versions, `go generate` results in whitespace changes. 2. Check that [Staticcheck](https://staticcheck.io/) passes. --- .github/workflows/go.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 79db8e4c..0682cb46 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -15,6 +15,8 @@ jobs: os: [ubuntu-latest, windows-latest] steps: - uses: actions/checkout@v2 + with: + fetch-depth: 1 - name: Set up Go uses: actions/setup-go@v2 @@ -26,3 +28,24 @@ jobs: - name: Test run: go test -v ./... + + - uses: dominikh/staticcheck-action@v1.2.0 + with: + version: "2022.1.3" + install-go: false + + generate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 1 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.19 + + - name: Test `go fmt && go generate` on Go 1.19 creates no diffs + run: go fmt && go generate && git diff --exit-code +