Added init and tidy targets to makefile

The docker build fails if the go.sums file needs to be updated.
In the original article, this required a local go install to run
the metadata update commands.

This change updates the Makefile and documentation to add two new
utility targets
This commit is contained in:
sjc
2021-06-28 13:29:38 -04:00
parent 143cc15e48
commit 4635517834
2 changed files with 12 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ all: bin/example
test: lint unit-test test: lint unit-test
PLATFORM=local PLATFORM=local
UTIL_TAG=1.16.5-alpine
.PHONY: bin/example .PHONY: bin/example
bin/example: bin/example:
@@ -22,3 +23,11 @@ unit-test-coverage:
.PHONY: lint .PHONY: lint
lint: lint:
@docker build . --target lint @docker build . --target lint
.PHONY: tidy
tidy:
@docker run -t -i -v `pwd`:/src --workdir /src --rm golang:${UTIL_TAG} /usr/local/go/bin/go mod tidy
.PHONY: init
init:
@docker run -t -i -v `pwd`:/src --workdir /src --rm golang:${UTIL_TAG} /usr/local/go/bin/go mod init

View File

@@ -94,6 +94,9 @@ The [Makefile](./Makefile) is purely used to script the required `docker build`
commands as these can get quite long. You can replace this file with a scripting commands as these can get quite long. You can replace this file with a scripting
language of your choice. language of your choice.
Additional targets 'init' and 'tidy' are provided for updating the project
metadata in go.mod and go.sums. `make tidy` should be run whenever new requirements are added.
### CI ### CI
The CI is configured in the [ci.yaml file](./.github/workflows/ci.yaml). By The CI is configured in the [ci.yaml file](./.github/workflows/ci.yaml). By