feat: set up project skeleton for new CLI (#1)
* docs: fill in README * feat: initial setup of CLI, with help + version commands * build: add linters and Makefile * build: add initial CircleCI workflow
This commit is contained in:
22
etc/checkfmt.sh
Executable file
22
etc/checkfmt.sh
Executable file
@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
HAS_FMT_ERR=0
|
||||
# For every Go file in the project, excluding vendor...
|
||||
for file in $(go list -f '{{$dir := .Dir}}{{range .GoFiles}}{{printf "%s/%s\n" $dir .}}{{end}}' ./...); do
|
||||
# ... if file does not contain standard generated code comment (https://golang.org/s/generatedcode)...
|
||||
if ! grep -Exq '^// Code generated .* DO NOT EDIT\.$' $file; then
|
||||
FMT_OUT="$(gofmt -l -d -e $file)" # gofmt exits 0 regardless of whether it's formatted.
|
||||
GCI_OUT="$(go run github.com/daixiang0/gci -d $file)"
|
||||
if [[ -n "$FMT_OUT" || -n "$GCI_OUT" ]]; then
|
||||
HAS_FMT_ERR=1
|
||||
echo "Not formatted: $file"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$HAS_FMT_ERR" -eq "1" ]; then
|
||||
echo 'Commit includes files that are not formatted' && \
|
||||
echo 'run "make fmt"' && \
|
||||
echo ''
|
||||
fi
|
||||
exit "$HAS_FMT_ERR"
|
11
etc/checktidy.sh
Executable file
11
etc/checktidy.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
export GO111MODULE=on
|
||||
go mod tidy
|
||||
|
||||
if ! git --no-pager diff --exit-code -- go.mod go.sum; then
|
||||
>&2 echo "modules are not tidy, please run 'go mod tidy'"
|
||||
exit 1
|
||||
fi
|
Reference in New Issue
Block a user