First, install CompileDaemon:
1
| $ go get github.com/githubnemo/CompileDaemon && go install github.com/githubnemo/CompileDaemon
|
Then, from the root of the project, create a Make file:
And add the below content:
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
| GOCMD ?= go
GOBUILD = $(GOCMD) build
GOCLEAN = $(GOCMD) clean
GOTEST = $(GOCMD) test
GOGET = $(GOCMD) get
BINARY_NAME = project_name
BINARY_UNIX = $(BINARY_NAME)_unix
default: all
all: test build
build:
$(GOBUILD) -o ../$(BINARY_NAME) -v -ldflags="-X main.VERSION=$(TAG)"
test:
$(GOTEST) -v ./...
clean:
$(GOCLEAN)
rm -f $(BINARY_NAME)
rm -f $(BINARY_UNIX)
run: build
./$(BINARY_NAME)
dev:
CompileDaemon -build="$(GOBUILD) -o ../$(BINARY_NAME)" -command="../$(BINARY_NAME)" -color="true" -exclude-dir=.git -exclude=".#*"
|
Finally, from the root of your project:
Voila!