From e5ae6088650075d8514e72aa5d6787c44ca6d735 Mon Sep 17 00:00:00 2001 From: Niklas Fasching Date: Sat, 17 Apr 2021 15:48:41 +0200 Subject: [PATCH] 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'. ``` --- Makefile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 5d828ae..7faee6c 100644 --- a/Makefile +++ b/Makefile @@ -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