This repository has been archived by the owner on Apr 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
80 lines (61 loc) · 1.71 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
72
73
74
75
76
77
78
79
80
.PHONY: init install
all: init install
app=$(notdir $(shell pwd))
tool:
go get github.com/securego/gosec/cmd/gosec
sec:
@gosec ./...
@echo "[OK] Go security check was completed!"
init:
export GOPROXY=https://goproxy.cn
lint:
#golangci-lint run --enable-all
golangci-lint run ./...
fmt:
gofumports -w .
gofumpt -w .
gofmt -s -w .
go mod tidy
go fmt ./...
revive .
goimports -w .
install: init
go install -ldflags="-s -w" ./...
ls -lh ~/go/bin/${app}
linux: init
GOOS=linux GOARCH=amd64 go install -ldflags="-s -w" ./...
upx:
ls -lh ~/go/bin/${app}
upx ~/go/bin/${app}
ls -lh ~/go/bin/${app}
ls -lh ~/go/bin/linux_amd64/${app}
upx ~/go/bin/linux_amd64/${app}
ls -lh ~/go/bin/linux_amd64/${app}
test: init
#go test -v ./...
go test -v -race ./...
bench: init
#go test -bench . ./...
go test -tags bench -benchmem -bench . ./...
clean:
rm coverage.out
cover:
go test -v -race -coverpkg=./... -coverprofile=coverage.out ./...
coverview:
go tool cover -html=coverage.out
# https://hub.docker.com/_/golang
# docker run --rm -v "$PWD":/usr/src/myapp -v "$HOME/dockergo":/go -w /usr/src/myapp golang make docker
# docker run --rm -it -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang bash
# 静态连接 glibc
docker:
mkdir -p ~/dockergo
docker run --rm -v "$$PWD":/usr/src/myapp -v "$$HOME/dockergo":/go -w /usr/src/myapp mlallaouret/golang-libpcap:1.6 make dockerinstall
upx ${app}
dockerinstall:
go build -v -x -a -ldflags '-s -w -extldflags "-static"'
targz:
cd .. && rm -f httpcap.tar.gz && tar czvf httpcap.tar.gz --exclude .git --exclude .idea httpcap
static:
CGO_ENABLED=1 go build -a -tags netgo -ldflags '-w -s -extldflags "-static"' .
run:
sudo GOLOG_STDOUT=true httpcap -c assets/conf.yml -resp