@@ -25,63 +25,56 @@ system-info:
2525 @ echo " os: {{ os ()}} "
2626 @ echo " os family: {{ os_family ()}} "
2727
28- # format source code
29- format :
30- @ echo " Formatting source code ..."
31- gofmt -l -s -w .
32-
33- # detect outdated modules (requires https://github.com/psampaz/go-mod-outdated)
34- outdated :
35- go list -u -m -json all | go-mod-outdated -update
36-
37- # detect known vulnerabilities (requires https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck)
38- vulnerabilities :
39- govulncheck ./ ...
40-
4128# detect known vulnerabilities (requires https://github.com/sonatype-nexus-community/nancy)
4229audit :
4330 go list -json -m all | nancy sleuth --loud
4431
45- # run linters (requires https://github.com/dominikh/go-tools)
46- lint :
47- staticcheck -f stylish ./ ... || \
48- (echo " \n Run \` just explain <LintIdentifier, e.g. SA1006>\` for details." && \
49- exit 1 )
50-
51- # explain lint identifier (e.g., "SA1006")
52- explain lint -identifier :
53- staticcheck -explain {{ lint-identifier}}
32+ # build executable for local OS
33+ build : test-vanilla
34+ @ echo " Building executable for local OS ..."
35+ go build -trimpath -ldflags=" -X 'main.Version={{ version}} '" -o app cmd/ golang-docker-build-tutorial/ main.go
5436
55- # add missing module requirements for imported packages, removes requirements that aren't used anymore
56- tidy :
57- go mod tidy
37+ # show test coverage
38+ coverage :
39+ go test -coverprofile={{ coverage_profile_log}} ./ ...
40+ go tool cover -html={{ coverage_profile_log}}
5841
5942# show dependencies
6043deps :
6144 go mod graph
6245
63- # run tests with colorized output (requires https://github.com/kyoh86/richgo)
64- test * FLAGS :
65- richgo test -cover {{ FLAGS}} ./ ...
46+ # create a docker image (requires Docker)
47+ docker-image-create :
48+ @ echo " Creating a docker image ..."
49+ @ PROJECT_VERSION={{ version}} ./ create_image.sh
6650
67- # run tests (vanilla), used for CI workflow
68- test-vanilla * FLAGS :
69- go test -cover {{ FLAGS}} ./ ...
51+ # run the docker image (requires Docker)
52+ docker-image-run :
53+ @ echo " Running container from docker image ..."
54+ @ ./ start_container.sh
7055
71- # show test coverage
72- coverage :
73- go test -coverprofile={{ coverage_profile_log}} ./ ...
74- go tool cover -html={{ coverage_profile_log}}
56+ # size of the docker image (requires Docker)
57+ docker-image-size :
58+ @ docker images $DOCKER_IMAGE_NAME
7559
76- # run executable for local OS
77- run :
78- @ echo " Running golang-docker-build-tutorial with defaults ..."
79- go run -ldflags=" -X 'main.Version={{ version}} '" cmd/ golang-docker-build-tutorial/ main.go
60+ # explain lint identifier (e.g., "SA1006")
61+ explain lint -identifier :
62+ staticcheck -explain {{ lint-identifier}}
8063
81- # build executable for local OS
82- build : test-vanilla
83- @ echo " Building executable for local OS ..."
84- go build -trimpath -ldflags=" -X 'main.Version={{ version}} '" -o app cmd/ golang-docker-build-tutorial/ main.go
64+ # format source code
65+ format :
66+ @ echo " Formatting source code ..."
67+ gofmt -l -s -w .
68+
69+ # run linters (requires https://github.com/dominikh/go-tools)
70+ lint :
71+ staticcheck -f stylish ./ ... || \
72+ (echo " \n Run \` just explain <LintIdentifier, e.g. SA1006>\` for details." && \
73+ exit 1 )
74+
75+ # detect outdated modules (requires https://github.com/psampaz/go-mod-outdated)
76+ outdated :
77+ go list -u -m -json all | go-mod-outdated -update
8578
8679# build release executables for all supported platforms
8780release : test-vanilla
@@ -98,24 +91,31 @@ release: test-vanilla
9891 GOOS=linux GOARCH=arm64 \
9992 go build -trimpath -ldflags " -X 'main.Version={{ version}} ' -s -w" -o app_linux-arm64 cmd/ golang-docker-build-tutorial/ main.go
10093
101- # create a docker image (requires Docker)
102- docker-image-create :
103- @ echo " Creating a docker image ..."
104- @ PROJECT_VERSION={{ version}} ./ create_image.sh
105-
106- # size of the docker image (requires Docker)
107- docker-image-size :
108- @ docker images $DOCKER_IMAGE_NAME
109-
110- # run the docker image (requires Docker)
111- docker-image-run :
112- @ echo " Running container from docker image ..."
113- @ ./ start_container.sh
94+ # run executable for local OS
95+ run :
96+ @ echo " Running golang-docker-build-tutorial with defaults ..."
97+ go run -ldflags=" -X 'main.Version={{ version}} '" cmd/ golang-docker-build-tutorial/ main.go
11498
11599# send request to the app's HTTP endpoint (requires running container)
116100send-request-to-app :
117101 curl http:// localhost:8123 / status
118102
103+ # run tests with colorized output (requires https://github.com/kyoh86/richgo)
104+ test * FLAGS :
105+ richgo test -cover {{ FLAGS}} ./ ...
106+
107+ # run tests (vanilla), used for CI workflow
108+ test-vanilla * FLAGS :
109+ go test -cover {{ FLAGS}} ./ ...
110+
111+ # add missing module requirements for imported packages, removes requirements that aren't used anymore
112+ tidy :
113+ go mod tidy
114+
115+ # detect known vulnerabilities (requires https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck)
116+ vulnerabilities :
117+ govulncheck ./ ...
118+
119119# watch sources for changes and trigger a rebuild (requires https://github.com/watchexec/watchexec)
120120watch :
121121 # Watch all go files in the current directory and all subdirectories for
0 commit comments