@@ -12,6 +12,50 @@ permissions:
1212 pull-requests : read
1313
1414jobs :
15+ gofmt-unix :
16+ strategy :
17+ matrix :
18+ go : ["1.20"]
19+ os : [macos-latest, ubuntu-latest]
20+ name : gofmt
21+ runs-on : ${{ matrix.os }}
22+ steps :
23+ - uses : actions/checkout@v3
24+ - uses : actions/setup-go@v4
25+ with :
26+ go-version : ${{ matrix.go }}
27+ cache : true
28+ - name : Run format checks
29+ run : |
30+ if [ $(gofmt -d -l -e . | wc -l) -eq 0 ]; then
31+ printf 'Format Checks Have Passed!!!'
32+ else
33+ printf 'Format Checks Have Failed!\nPlease use gofmt in your system to format your code.'
34+ gofmt -l -e -d .
35+ exit 1
36+ fi
37+ gofmt-windows :
38+ strategy :
39+ matrix :
40+ go : ["1.20"]
41+ os : [windows-latest]
42+ name : gofmt
43+ runs-on : ${{ matrix.os }}
44+ steps :
45+ - uses : actions/checkout@v3
46+ - uses : actions/setup-go@v4
47+ with :
48+ go-version : ${{ matrix.go }}
49+ cache : true
50+ - name : Run format checks
51+ run : |
52+ if ((gofmt -d -l -e . | Measure-Object -Line).Lines -eq 0) {
53+ Write-Host 'Format Checks Have Passed!!!'
54+ } else {
55+ Write-Host 'Format Checks Have Failed!'
56+ gofmt -l -e -d .
57+ exit 1
58+ }
1559 golangci :
1660 strategy :
1761 matrix :
4488
4589 - name : Run staticcheck
4690 run : staticcheck ./...
47-
48- - name : Run format checks
49- run : |
50- if ["${{ matrix.os }}" == "windows-latest"]; then
51- if ((gofmt -d -l -e . | Measure-Object -Line).Lines -eq 0) {
52- Write-Host 'Format Checks Have Passed!!!'
53- } else {
54- Write-Host 'Format Checks Have Failed!'
55- gofmt -l -e -d .
56- exit 1
57- }
58- else
59- if [ $(gofmt -d -l -e . | wc -l) -eq 0 ]; then
60- printf 'Format Checks Have Passed!!!'
61- else
62- printf 'Format Checks Have Failed!\nPlease use gofmt in your system to format your code.'
63- gofmt -l -e -d .
64- exit 1
65- fi
66- fi
0 commit comments