Workflows #10
Workflow file for this run
This file contains 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: Go Lint | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ '**' ] | |
jobs: | |
golangci: | |
name: lint | |
runs-on: ubuntu-latest | |
steps: | |
# 检出代码 | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.21' | |
cache: true | |
- name: Install dependencies | |
run: go mod download | |
- name: Run golangci-lint | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
version: latest | |
args: --timeout=5m | |
- name: Check code formatting | |
run: | | |
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then | |
echo "Code is not properly formatted. Please run 'go fmt'" | |
gofmt -s -l . | |
exit 1 | |
fi | |
- name: Run go vet | |
run: go vet ./... |