gofmt.yml 674 B

12345678910111213141516171819202122232425262728293031323334
  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. - uses: actions/checkout@v4
  16. - uses: actions/setup-go@v5
  17. with:
  18. go-version: '1.23'
  19. check-latest: true
  20. - name: Install goimports
  21. run: |
  22. go install golang.org/x/tools/cmd/goimports@latest
  23. - name: gofmt
  24. run: |
  25. if [ "$(find . -iname '*.go' | grep -v '\.pb\.go$' | xargs goimports -l)" ]
  26. then
  27. find . -iname '*.go' | grep -v '\.pb\.go$' | xargs goimports -d
  28. exit 1
  29. fi