Skip to content

Commit

Permalink
put variable in makefile for go so I can run 'make GOBIN=go1.23rc1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ldemailly committed Jul 1, 2024
1 parent 8f090f7 commit 8c8094b
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@

GOBIN:=$(GOBIN)

all: test example

test:
go test -race ./...
go test -tags no_json ./...
go test -tags no_http ./...
$(GOBIN) test -race ./...
$(GOBIN) test -tags no_json ./...
$(GOBIN) test -tags no_http ./...

local-coverage: coverage
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
$(GOBIN) test -coverprofile=coverage.out ./...
$(GOBIN) tool cover -html=coverage.out

coverage:
go test -coverprofile=coverage1.out ./...
go test -tags no_net -coverprofile=coverage2.out ./...
go test -tags no_json -coverprofile=coverage3.out ./...
go test -tags no_http,no_json -coverprofile=coverage4.out ./...
$(GOBIN) test -coverprofile=coverage1.out ./...
$(GOBIN) test -tags no_net -coverprofile=coverage2.out ./...
$(GOBIN) test -tags no_json -coverprofile=coverage3.out ./...
$(GOBIN) test -tags no_http,no_json -coverprofile=coverage4.out ./...
# cat coverage*.out > coverage.out
go install github.com/wadey/gocovmerge@b5bfa59ec0adc420475f97f89b58045c721d761c
$(GOBIN) install github.com/wadey/gocovmerge@b5bfa59ec0adc420475f97f89b58045c721d761c
gocovmerge coverage?.out > coverage.out

example:
@echo "### Colorized (default) ###"
go run ./levelsDemo
$(GOBIN) run ./levelsDemo
@echo "### JSON: (redirected stderr) ###"
go run ./levelsDemo 3>&1 1>&2 2>&3 | jq -c
$(GOBIN) run ./levelsDemo 3>&1 1>&2 2>&3 | jq -c

line:
@echo
Expand All @@ -34,13 +36,13 @@ screenshot: line example

size-check:
@echo "### Size of the binary:"
CGO_ENABLED=0 go build -ldflags="-w -s" -trimpath -o ./fullsize ./levelsDemo
CGO_ENABLED=0 $(GOBIN) build -ldflags="-w -s" -trimpath -o ./fullsize ./levelsDemo
ls -lh ./fullsize
CGO_ENABLED=0 go build -tags no_net -ldflags="-w -s" -trimpath -o ./smallsize ./levelsDemo
CGO_ENABLED=0 $(GOBIN) build -tags no_net -ldflags="-w -s" -trimpath -o ./smallsize ./levelsDemo
ls -lh ./smallsize
CGO_ENABLED=0 go build -tags no_http,no_json -ldflags="-w -s" -trimpath -o ./smallsize ./levelsDemo
CGO_ENABLED=0 $(GOBIN) build -tags no_http,no_json -ldflags="-w -s" -trimpath -o ./smallsize ./levelsDemo
ls -lh ./smallsize
gsa ./smallsize # go install github.com/Zxilly/go-size-analyzer/cmd/gsa@master
gsa ./smallsize # $(GOBIN) install github.com/Zxilly/$(GOBIN)-size-analyzer/cmd/gsa@master


lint: .golangci.yml
Expand Down

0 comments on commit 8c8094b

Please sign in to comment.