2019-12-11 20:31:35 -07:00
|
|
|
name: gofmt
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
pull_request:
|
2020-03-02 14:21:19 -07:00
|
|
|
paths:
|
|
|
|
- '.github/workflows/gofmt.yml'
|
|
|
|
- '**.go'
|
2019-12-11 20:31:35 -07:00
|
|
|
jobs:
|
|
|
|
|
|
|
|
gofmt:
|
|
|
|
name: Run gofmt
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
|
2023-05-23 11:24:33 -06:00
|
|
|
- uses: actions/checkout@v3
|
2019-12-11 20:31:35 -07:00
|
|
|
|
2023-05-23 11:24:33 -06:00
|
|
|
- uses: actions/setup-go@v4
|
2020-06-30 16:53:30 -06:00
|
|
|
with:
|
2023-05-23 11:24:33 -06:00
|
|
|
go-version-file: 'go.mod'
|
|
|
|
check-latest: true
|
2020-06-30 16:53:30 -06:00
|
|
|
|
|
|
|
- name: Install goimports
|
|
|
|
run: |
|
2023-05-04 09:35:03 -06:00
|
|
|
go install golang.org/x/tools/cmd/goimports@latest
|
2020-06-30 16:53:30 -06:00
|
|
|
|
2019-12-11 20:31:35 -07:00
|
|
|
- name: gofmt
|
|
|
|
run: |
|
2023-05-04 09:35:03 -06:00
|
|
|
if [ "$(find . -iname '*.go' | grep -v '\.pb\.go$' | xargs goimports -l)" ]
|
2019-12-11 20:31:35 -07:00
|
|
|
then
|
2023-05-04 09:35:03 -06:00
|
|
|
find . -iname '*.go' | grep -v '\.pb\.go$' | xargs goimports -d
|
2019-12-11 20:31:35 -07:00
|
|
|
exit 1
|
|
|
|
fi
|