-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
71 lines (50 loc) · 1.75 KB
/
Makefile
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
.PHONY: build run gorun compile lint test test_race test_coverage check_coverage mocks dep vet errcheck install_tools docker_build docker_run docker_run_detach docker_start docker_remove docker_exec
BINARY_NAME=tcptracker
DEVICE=eth0
build:
go build -o bin/${BINARY_NAME} ./cmd/main.go
gorun:
go run ./cmd/main.go
run:
sudo setcap cap_net_admin,cap_net_raw+ep ./bin/tcptracker
sudo ./bin/tcptracker -deviceName ${DEVICE}
fmt:
go fmt ./...
lint:
golangci-lint --version
golangci-lint --config ./.golangci.yml linters
golangci-lint --config ./.golangci.yml run --timeout 5m
test:
go test -v ./...
test_race:
go test -v -race ./...
test_coverage:
go test -v ./... -coverprofile=coverage.out
check_coverage:
go tool cover -html=coverage.out
mocks: # TODO make it dynamic
mockgen -source=internal/connectiontracker/firewall.go -package=mock -destination=mock/gomock_firewall.go Firewall
mockgen -source=internal/connectiontracker/firewall_test.go -package=mock -destination=mock/gomock_ipTableCoreos.go ipTableCoreos
dep:
go mod tidy
vet:
go vet ./...
errcheck:
errcheck ./...
install_tools:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.46.2
golangci-lint --version
go install github.com/kisielk/errcheck@latest
go install github.com/golang/mock/[email protected]
docker_build:
docker build -t ${BINARY_NAME} .
docker_run:
docker run --name ${BINARY_NAME} --net=host --cap-add NET_ADMIN -t tcptracker:latest -deviceName ${DEVICE}
docker_run_detach:
docker run -d --name ${BINARY_NAME} --net=host --cap-add NET_ADMIN -t tcptracker:latest -deviceName ${DEVICE}
docker_start:
docker start tcptracker
docker_exec:
docker exec -it tcptracker sh
docker_remove:
docker rm tcptracker