-
Notifications
You must be signed in to change notification settings - Fork 25
/
Makefile
38 lines (29 loc) · 876 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
PKG:=github.com/kayrus/gof5
APP_NAME:=gof5
PWD:=$(shell pwd)
UID:=$(shell id -u)
VERSION:=$(shell git describe --tags --always --dirty="-dev")
GOOS:=$(shell go env GOOS)
LDFLAGS:=-X main.Version=$(VERSION) -w -s
GOOS:=$(strip $(shell go env GOOS))
GOARCHs:=$(strip $(shell go env GOARCH))
ifeq "$(GOOS)" "windows"
SUFFIX=.exe
endif
# CGO must be enabled
export CGO_ENABLED:=1
build: fmt vet
$(foreach GOARCH,$(GOARCHs),$(shell GOARCH=$(GOARCH) go build -mod=vendor -ldflags="$(LDFLAGS)" -trimpath -o bin/$(APP_NAME)_$(GOOS)_$(GOARCH)$(SUFFIX) ./cmd/gof5))
docker:
docker pull golang:latest
docker run -ti --rm -e GOCACHE=/tmp -v $(PWD):/$(APP_NAME) -u $(UID):$(UID) --workdir /$(APP_NAME) golang:latest make
fmt:
gofmt -s -w cmd pkg
vet:
go vet -mod=vendor ./...
static:
staticcheck ./cmd/... ./pkg/...
mod:
go mod vendor
test:
go test -v ./cmd/... ./pkg/...