From 71d0f98139871fae65fd5738d4f021d4a9c809ae Mon Sep 17 00:00:00 2001 From: WheeskyJack Date: Thu, 27 Jun 2024 18:34:38 +0530 Subject: [PATCH] add golangci linter in github workflow action enable basic linters using golangci-lint tool --- .github/workflows/golangci-lint.yml | 37 +++++++++++++++++++++++++++++ .golangci.yml | 21 ++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 .github/workflows/golangci-lint.yml create mode 100644 .golangci.yml diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 0000000..26eb374 --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,37 @@ +name: golangci-lint + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + golangci: + name: golangci-lint + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.22' + cache: false + - name: Run golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + version: v1.59 + + # Optional: working directory, useful for monorepos + # working-directory: somedir + + # Optional: golangci-lint command line arguments. + # + # Note: By default, the `.golangci.yml` file should be at the root of the repository. + # The location of the configuration file can be changed by using `--config=` + # args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0 + args: --verbose \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..8c45095 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,21 @@ +run: + timeout: 5m + exclude-dirs: + - vendor + - examples + +linters: + enable: + - errcheck + - gocyclo + - gofmt + - goimports + - gosimple + - govet + - ineffassign + - staticcheck + - unused + +linters-settings: + gocyclo: + min-complexity: 20 \ No newline at end of file