gofmt.yml 985 B

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