fix Makefile and go.yml

This commit is contained in:
Bora M. Alper 2020-11-27 19:49:26 +00:00
parent 2654d9507a
commit 4e27c2e1f4
No known key found for this signature in database
GPG Key ID: 8F1A9504E1BD114D
2 changed files with 17 additions and 4 deletions

View File

@ -7,7 +7,6 @@ on:
branches: [ master ]
jobs:
build:
name: Build
runs-on: ubuntu-latest
@ -33,7 +32,11 @@ jobs:
- name: Test
run: |
make test
- name: Lint
run: |
make staticcheck
- name: Check Formatting
run: |
make check-formatting

View File

@ -61,7 +61,17 @@ format:
# Because `read` is a bash command.
# https://stackoverflow.com/a/589300/4466589
#
# How to ignore bindata.go
# Due to irrational insistence of some Go developers, gofmt, like many
# other tools of Go ecosystem, does not have flags for common scenarios
# such as ignoring certain files by pattern etc. Thus we use `go list`
# and grep together to achieve the desired result.
#
# The original query is this:
# gofmt -l $(go list -f $'{{range .GoFiles}}{{$.Dir}}/{{.}}\n{{end}}' ./... | grep -v bindata.go)
#
# The original query is then escaped for Makefile (by repeating dollar signs $ -> $$).
check-formatting: SHELL:=/bin/bash # HERE: this is setting the shell for check-formatting only
check-formatting:
! gofmt -l ./cmd/ 2>&1 | tee /dev/fd/2 | read
! gofmt -l ./pkg/ 2>&1 | tee /dev/fd/2 | read
! gofmt -l $$(go list -f $$'{{range .GoFiles}}{{$$.Dir}}/{{.}}\n{{end}}' ./... | grep -v bindata.go) 2>&1 | tee /dev/fd/2 | read
! gofmt -l $$(go list -f $$'{{range .GoFiles}}{{$$.Dir}}/{{.}}\n{{end}}' ./... | grep -v bindata.go) 2>&1 | tee /dev/fd/2 | read