From ed4e7f8063555ab2448f843214eedc36d3458360 Mon Sep 17 00:00:00 2001 From: Sophia Wang Date: Sat, 23 Nov 2024 03:07:36 +0800 Subject: [PATCH] Add go lint (#10) This is the simple use of golangci-lint-action. The enabled by default linters as follows: errcheck, gosimple, govet, ineffassign, staticcheck, unused. The gosec, goimports are included in the linters. Signed-off-by: Sophia Wang --- .github/workflows/go_lint.yml | 23 +++++++++++++++++++++++ .golangci.yml | 10 ++++++++++ 2 files changed, 33 insertions(+) create mode 100644 .github/workflows/go_lint.yml create mode 100644 .golangci.yml diff --git a/.github/workflows/go_lint.yml b/.github/workflows/go_lint.yml new file mode 100644 index 0000000..6365519 --- /dev/null +++ b/.github/workflows/go_lint.yml @@ -0,0 +1,23 @@ +name: golangci-lint +on: + push: + branches: + - main + pull_request: + +permissions: + contents: read + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version-file: './go.mod' + - name: golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + version: v1.60 diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..2a7a765 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,10 @@ +linters: + enable: + - errcheck # Checks for unchecked errors + - gosimple # Finds code simplifications + - govet # Vet checks for various errors + - ineffassign # Finds useless assignments + - staticcheck # Comprehensive static analysis + - unused # Finds unused variables, functions, etc. + - gosec # Security checks for Go code + - goimports # Checks import statements are formatted