Created
February 10, 2016 16:29
-
-
Save alixaxel/43bd25d7b1b6577db2a1 to your computer and use it in GitHub Desktop.
Golang Makefile
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
.PHONY: build doc fmt lint run test vendor_clean vendor_get vendor_update vet | |
# Prepend our _vendor directory to the system GOPATH | |
# so that import path resolution will prioritize | |
# our third party snapshots. | |
GOPATH := ${PWD}/_vendor:${GOPATH} | |
export GOPATH | |
default: build | |
build: vet | |
go build -v -o ./bin/main_app ./src/main_app | |
doc: | |
godoc -http=:6060 -index | |
# http://golang.org/cmd/go/#hdr-Run_gofmt_on_package_sources | |
fmt: | |
go fmt ./src/... | |
# https://github.com/golang/lint | |
# go get github.com/golang/lint/golint | |
lint: | |
golint ./src | |
run: build | |
./bin/main_app | |
test: | |
go test ./src/... | |
vendor_clean: | |
rm -dRf ./_vendor/src | |
# We have to set GOPATH to just the _vendor | |
# directory to ensure that `go get` doesn't | |
# update packages in our primary GOPATH instead. | |
# This will happen if you already have the package | |
# installed in GOPATH since `go get` will use | |
# that existing location as the destination. | |
vendor_get: vendor_clean | |
GOPATH=${PWD}/_vendor go get -d -u -v \ | |
github.com/jpoehls/gophermail \ | |
github.com/codegangsta/martini | |
vendor_update: vendor_get | |
rm -rf `find ./_vendor/src -type d -name .git` \ | |
&& rm -rf `find ./_vendor/src -type d -name .hg` \ | |
&& rm -rf `find ./_vendor/src -type d -name .bzr` \ | |
&& rm -rf `find ./_vendor/src -type d -name .svn` | |
# http://godoc.org/code.google.com/p/go.tools/cmd/vet | |
# go get code.google.com/p/go.tools/cmd/vet | |
vet: | |
go vet ./src/... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment