Created
February 6, 2019 18:28
-
-
Save xealgo/051dc441efde451e3644073e5f3fd618 to your computer and use it in GitHub Desktop.
Make file I use in go projects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BUILD := $(shell date +%m%d%H%M%S) | |
BUILD_TIME := $(shell date +%d.%m.%y@%H:%M:%S) | |
BUILD_COMMIT := $(shell git rev-parse HEAD) | |
BUILD_BRANCH := $(shell git rev-parse --abbrev-ref HEAD) | |
VERSION := "0.0.1" | |
default: build-dev | |
.PHONY: default build-dev dev run test vet lint fmt | |
build-dev: | |
@go build -o ./bin/project -tags dev -ldflags "-X main.Version=$(VERSION) -X main.Env=dev -X main.Build=$(BUILD) -X main.BuildTime=$(BUILD_TIME) -X main.BuildCommit=$(BUILD_COMMIT) -X main.BuildBranch=$(BUILD_BRANCH)" ./cmd/project | |
build: | |
@go build -o ./bin/project -tags prod -ldflags "-X main.Version=$(VERSION) -X main.Env=prod -X main.Build=$(BUILD) -X main.BuildTime=$(BUILD_TIME) -X main.BuildCommit=$(BUILD_COMMIT) -X main.BuildBranch=$(BUILD_BRANCH)" ./cmd/project | |
dev: | |
@make build-dev | |
@cd ./bin && ./project | |
run: | |
@make build | |
@cd ./bin && ./project | |
test: | |
@go test -v ./... | |
vet: | |
@go tool vet --all -shadow . | |
lint: | |
@golint ./... | |
fmt: | |
@go fmt -x ./... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment