Improve Makefile: Only install dependencies and rebuild when required

By getting rid of the PHONY install and bundling the go get with its uses we
can prevent unnecessary go gets in `make build` - this speeds up development as
I run `make generate-fixtures` a lot and fetching dependencies takes
comparatively long.

We also add the `-d` flag to go get to get rid of the deprecation warning
```
go get: installing executables with 'go get' in module mode is deprecated.
	To adjust and download dependencies of the current module, use 'go get -d'.
	To install using requirements of the current module, use 'go install'.
	To install ignoring the current module, use 'go install' with a version,
	like 'go install example.com/cmd@latest'.
	For more information, see https://golang.org/doc/go-get-install-deprecation
	or run 'go help get' or 'go help install'.
```
This commit is contained in:
Niklas Fasching 2021-04-17 15:48:41 +02:00
parent 21f1af7d48
commit e5ae608865

View file

@ -1,16 +1,16 @@
.PHONY: default
default: test
.PHONY: install
install:
go get -t ./...
.PHONY: build
build: install
go-org: *.go */*.go go.mod go.sum
go get -d ./...
go build .
.PHONY: build
build: go-org
.PHONY: test
test: install
test:
go get -d -t ./...
go test ./... -v
.PHONY: setup