From 18b0d52b3f5c2e8b5c777333b1370955be717c3d Mon Sep 17 00:00:00 2001 From: Antonio Navarro Perez Date: Mon, 27 Jul 2020 12:19:35 +0200 Subject: [PATCH] Add Makefile Signed-off-by: Antonio Navarro Perez --- .gitignore | 3 +- Makefile | 61 +++++++++++++++++++++++++ cmd/distribyted/main.go | 4 +- conf.yaml => examples/conf_example.yaml | 0 4 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 Makefile rename conf.yaml => examples/conf_example.yaml (100%) diff --git a/.gitignore b/.gitignore index 6981995..ab4abe1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ _DATA -httpfs_vfsdata.go \ No newline at end of file +httpfs_vfsdata.go +bin/ \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..76d43dd --- /dev/null +++ b/Makefile @@ -0,0 +1,61 @@ +#-include .env + +VERSION := $(shell git describe --tags) +BUILD := $(shell git rev-parse --short HEAD) +PROJECTNAME := $(shell basename "$(PWD)") + +# Use linker flags to provide version/build settings +LDFLAGS=-ldflags "-X=main.Version=$(VERSION) -X=main.Build=$(BUILD)" + +# Make is verbose in Linux. Make it silent. +MAKEFLAGS += --silent + +## run: run from code. +run: + go run cmd/distribyted/main.go examples/conf_example.yaml + +## build: build binary. +build: go-generate go-build + +## test: execute all tests. +test: + go test -v ./... + +compile: go-generate go-compile + +go-build: + @echo " > Building binary..." + go build $(LDFLAGS) -o bin/distribyted -tags "release" cmd/distribyted/main.go + +go-generate: + @echo " > Generating code files..." + go generate ./... + +go-compile: + @echo " > Compiling for several platforms..." + # 32-Bit Systems + # FreeBDS + #GOOS=freebsd GOARCH=386 go build $(LDFLAGS) -o bin/main-freebsd-386 -tags "release" cmd/distribyted/main.go + # MacOS + #GOOS=darwin GOARCH=386 go build $(LDFLAGS) -o bin/main-darwin-386 -tags "release" cmd/distribyted/main.go + # Linux + GOOS=linux GOARCH=386 go build $(LDFLAGS) -o bin/main-linux-386 -tags "release" cmd/distribyted/main.go + # 64-Bit + # FreeBDS + #GOOS=freebsd GOARCH=amd64 go build $(LDFLAGS) -o bin/main-freebsd-amd64 -tags "release" cmd/distribyted/main.go + # MacOS + #GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o bin/main-darwin-amd64 -tags "release" cmd/distribyted/main.go + # Linux + GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o bin/main-linux-amd64 -tags "release" cmd/distribyted/main.go + + # ARM + GOOS=linux GOARCH=arm GOARM=5 go build $(LDFLAGS) -o bin/main-linux-arm -tags "release" cmd/distribyted/main.go + +.PHONY: help +all: help +help: Makefile + @echo + @echo " Choose a command run in "$(PROJECTNAME)":" + @echo + @sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /' + @echo \ No newline at end of file diff --git a/cmd/distribyted/main.go b/cmd/distribyted/main.go index 257043b..fd8fe3c 100644 --- a/cmd/distribyted/main.go +++ b/cmd/distribyted/main.go @@ -99,6 +99,8 @@ func main() { } } + gin.SetMode(gin.ReleaseMode) + r := gin.New() r.Use(ginlogrus.Logger(log), gin.Recovery()) @@ -112,8 +114,6 @@ func main() { r.SetHTMLTemplate(t) - // r.LoadHTMLGlob("templates/*") - r.GET("/", func(c *gin.Context) { c.HTML(http.StatusOK, "index.html", nil) }) diff --git a/conf.yaml b/examples/conf_example.yaml similarity index 100% rename from conf.yaml rename to examples/conf_example.yaml