summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2022-07-08 18:42:28 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2022-07-08 18:42:28 -0600
commit28025da170fdd77bf12dd4d9cdb663da0ea0679a (patch)
tree7093eef775aec2046440827decd605d9b84b23f0 /Makefile
parent1d79b0ef6993c883e1f81dac5fe272b71d9075b2 (diff)
Add a Makefile that runs lint and stuff
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile37
1 files changed, 37 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..73263d0
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,37 @@
+# main
+
+build:
+ go build -o bin/ ./cmd/...
+.PHONY: build
+
+check:
+ go test -race ./...
+.PHONY: check
+
+lint: tools/bin/golangci-lint
+ tools/bin/golangci-lint run ./...
+.PHONY: lint
+
+# tools
+
+tools/bin/%: tools/src/%/pin.go tools/src/%/go.mod
+ cd $(<D) && GOOS= GOARCH= go build -o $(abspath $@) $$(sed -En 's,^import "(.*)".*,\1,p' pin.go)
+
+# go mod tidy
+
+goversion = 1.18
+
+go-mod-tidy:
+.PHONY: go-mod-tidy
+
+go-mod-tidy: go-mod-tidy/main
+go-mod-tidy/main:
+ rm -f go.sum
+ go mod tidy -go $(goversion) -compat $(goversion)
+.PHONY: go-mod-tidy/main
+
+go-mod-tidy: $(patsubst tools/src/%/go.mod,go-mod-tidy/tools/%,$(wildcard tools/src/*/go.mod))
+go-mod-tidy/tools/%: tools/src/%/go.mod
+ rm -f tools/src/$*/go.sum
+ cd tools/src/$* && go mod tidy -go $(goversion) -compat $(goversion)
+.PHONY: go-mod-tidy/tools/%