Skip to content

Instantly share code, notes, and snippets.

@zaky
Created March 14, 2016 08:13
Show Gist options
  • Select an option

  • Save zaky/5eacc1d03411cae2dbb4 to your computer and use it in GitHub Desktop.

Select an option

Save zaky/5eacc1d03411cae2dbb4 to your computer and use it in GitHub Desktop.
OUTPUT = rating_migration_cli
PACKAGE= github.com/gtforge/cli_rating
GOARCH=amd64
define GRAPH_BODY
( echo "digraph G {"
go list -f '{{range .Imports}}{{printf "\t%q -> %q;\n" $$.ImportPath .}}{{end}}' $$(go list -f '{{join .Deps " "}}' github.com/gtforge/cli_rating) github.com/gtforge/cli_rating
echo "}"
) | dot -Tsvg -o deps.svg && firefox deps.svg
endef
export GRAPH_BODY
default: all
all: get fmt vet lint build
run:
go run $(runfile)
fmt:
go fmt
get:
go get
vet:
go vet
lint:
golint
imports:
goimports
build:
go build -o $(OUTPUT)
build-mac:
GOARCH=amd64 GOOS=darwin go build -o $(OUTPUT).osx
exec:
./$(OUTPUT)
test:
go test -coverprofile=cover.out
go tool cover -html=cover.out
testone:
#Sample make test=TestValid testone
go test -v -run $(test)
integration:
go test -tags=integration -coverprofile=int-cover.out
go tool cover -html=int-cover.out
race:
go test -race $(PACKAGE)
#GORACE="log_path=/tmp/race_report" go test -race $(PACKAGE)
#REPORT=`ls -rt /tmp/race_report* | tail -1`
#xdg-open file://$(REPORT)
doc:
godoc -http=:6060 &
sleep 3
xdg-open http://127.0.0.1:6060/pkg/github.com/gtforge/cli_rating/ &
show: test doc
clean:
rm -f $(OUTPUT) ws_rating
rm -f cover.out int-cover.out
rm -f $(OUTPUT).tar.bz2
#Delete tilda files in sub folders also
find . -type f -name '*~' -delete
profile:
#Insert cpu profile code
#goimports
#Generate cpu profile
#Generate image and display it
#Insert memory profile code
#goimports
#Generate memory profile
#Generate image and display it
list:
go list -f '{{ join .Imports "\n" }}' $(PACKAGE)
eval "$$GRAPH_BODY"
depend:
go get -u github.com/golang/lint/golint
go get -u github.com/bradfitz/goimports
#Install graphviz for svg profile output
sudo aptitude install graphviz
#Add to ~/.bashrc
#printf "export PATH=$PATH:$GOPATH/bin"
compress: clean bz2
bz2:
tar -jcvf $(OUTPUT).tar.bz2 *.go Makefile README.md pg.sql fossil-config fossil-ws_rating .fslckout
tar -jtf $(OUTPUT).tar.bz2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment