Skip to content

Commit 9e4cc2b

Browse files
authored
Refine go lint to skip go.sum check when not needed (#19)
In a project without any dependencies there is no go.sum. Do not fail the lint for it. Also cover the opposite case where go.sum is not checked in.
1 parent 297f412 commit 9e4cc2b

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

.github/workflows/go-lint.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,17 @@ jobs:
2525
if: hashFiles('./.github/actions/go-lint-setup') != ''
2626
- name: Check module tidiness
2727
run: |
28+
had_sum=$( [ -f go.sum ] && echo true || echo false )
2829
go mod tidy
2930
git diff --exit-code go.mod
30-
git diff --exit-code go.sum
31+
if [ -f go.sum ]; then
32+
if [ "$had_sum" = true ]; then
33+
git diff --exit-code go.sum
34+
else
35+
echo "error: go.sum was created by 'go mod tidy' but is not checked in"
36+
exit 1
37+
fi
38+
fi
3139
- name: Vet Go files
3240
if: always()
3341
run: go vet ./...

0 commit comments

Comments
 (0)