| 1 | name: gofmt |
| 2 | on: |
| 3 | push: |
| 4 | branches: |
| 5 | - main |
| 6 | pull_request: |
| 7 | paths: |
| 8 | - '.github/workflows/gofmt.yml' |
| 9 | - '.github/workflows/gofmt.sh' |
| 10 | - '**.go' |
| 11 | jobs: |
| 12 | |
| 13 | gofmt: |
| 14 | name: Run gofmt |
| 15 | runs-on: ubuntu-latest |
| 16 | steps: |
| 17 | |
| 18 | - name: Set up Go 1.16 |
| 19 | uses: actions/setup-go@v2 |
| 20 | with: |
| 21 | go-version: 1.16 |
| 22 | id: go |
| 23 | |
| 24 | - name: Check out code into the Go module directory |
| 25 | uses: actions/checkout@v2 |
| 26 | |
| 27 | - uses: actions/cache@v2 |
| 28 | with: |
| 29 | path: ~/go/pkg/mod |
| 30 | key: ${{ runner.os }}-gofmt-${{ hashFiles('**/go.sum') }} |
| 31 | restore-keys: | |
| 32 | ${{ runner.os }}-gofmt- |
| 33 | |
| 34 | - name: Install goimports |
| 35 | run: | |
| 36 | go get golang.org/x/tools/cmd/goimports |
| 37 | go build golang.org/x/tools/cmd/goimports |
| 38 | |
| 39 | - name: gofmt |
| 40 | run: $GITHUB_WORKSPACE/.github/workflows/gofmt.sh |