style: apply lint #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Lint | |
| on: | |
| push: | |
| branches: ["**"] | |
| pull_request: | |
| branches: ["**"] | |
| env: | |
| GO_VERSION: "1.24" | |
| jobs: | |
| lint: | |
| name: Lint Code | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| cache-dependency-path: go.sum | |
| - name: Cache Go build cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/go-build | |
| key: ${{ runner.os }}-go${{ env.GO_VERSION }}-build-${{ hashFiles('go.sum') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go${{ env.GO_VERSION }}-build- | |
| ${{ runner.os }}-go-build- | |
| - name: Cache golangci-lint | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/golangci-lint | |
| key: ${{ runner.os }}-golangci-lint-${{ hashFiles('**/go.sum') }} | |
| restore-keys: | | |
| ${{ runner.os }}-golangci-lint- | |
| - name: Run golangci-lint | |
| uses: golangci/golangci-lint-action@v4 | |
| with: | |
| version: latest | |
| args: --timeout=5m | |
| cache: true | |
| - name: Check formatting | |
| run: | | |
| if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then | |
| echo "Code is not formatted. Run 'gofmt -s -w .'" | |
| gofmt -s -d . | |
| exit 1 | |
| fi | |
| - name: Run go vet | |
| run: go vet ./... | |
| - name: Verify dependencies | |
| run: go mod verify | |
| - name: Check for unused dependencies | |
| run: | | |
| go mod tidy | |
| if [ -n "$(git status --porcelain go.mod go.sum)" ]; then | |
| echo "go.mod or go.sum is not up to date. Run 'go mod tidy'" | |
| git diff go.mod go.sum | |
| exit 1 | |
| fi |