| 1 | NO_COLOR=\033[0m |
| 2 | OK_COLOR=\033[0;32m |
| 3 | |
| 4 | all: format vet lint |
| 5 | |
| 6 | format: |
| 7 | @echo "$(OK_COLOR)==> Formatting the code $(NO_COLOR)" |
| 8 | @gofmt -s -w *.go |
| 9 | @goimports -w *.go || true |
| 10 | |
| 11 | test-privileged: |
| 12 | @echo "$(OK_COLOR)==> Running tests for privileged user $(NO_COLOR)" |
| 13 | @sudo `which go` test -v -coverprofile=/tmp/priv.out |
| 14 | @sudo `which go` test -tags static_build -v -coverprofile=/tmp/priv.out |
| 15 | |
| 16 | test-privileged-race: |
| 17 | @echo "$(OK_COLOR)==> Running tests with -race flag for privileged user $(NO_COLOR)" |
| 18 | @sudo `which go` test -race -v |
| 19 | @sudo `which go` test -tags static_build -race -v |
| 20 | |
| 21 | test: |
| 22 | @echo "$(OK_COLOR)==> Running tests for unprivileged user $(NO_COLOR)" |
| 23 | @`which go` test -v -coverprofile=/tmp/unpriv.out |
| 24 | @`which go` test -tags static_build -v -coverprofile=/tmp/unpriv.out |
| 25 | |
| 26 | test-race: |
| 27 | @echo "$(OK_COLOR)==> Running tests with -race flag for unprivileged user $(NO_COLOR)" |
| 28 | @`which go` test -race -v |
| 29 | @`which go` test -tags static_build -race -v |
| 30 | |
| 31 | cover: |
| 32 | @echo "$(OK_COLOR)==> Running cover for privileged user $(NO_COLOR)" |
| 33 | @`which go` tool cover -func=/tmp/priv.out || true |
| 34 | @echo "$(OK_COLOR)==> Running cover for unprivileged user $(NO_COLOR)" |
| 35 | @`which go` tool cover -func=/tmp/unpriv.out || true |
| 36 | |
| 37 | doc: |
| 38 | @`which go` doc github.com/lxc/go-lxc | less |
| 39 | |
| 40 | vet: |
| 41 | @echo "$(OK_COLOR)==> Running go vet $(NO_COLOR)" |
| 42 | @`which go` vet . |
| 43 | |
| 44 | lint: |
| 45 | @echo "$(OK_COLOR)==> Running golint $(NO_COLOR)" |
| 46 | @`which golint` . || true |
| 47 | |
| 48 | escape-analysis: |
| 49 | @`which go` build -gcflags -m |
| 50 | |
| 51 | ctags: |
| 52 | @ctags -R --languages=c,go |
| 53 | |
| 54 | update-gomod: |
| 55 | go get -t -v -d -u ./... |
| 56 | go mod tidy |
| 57 | |
| 58 | scope: |
| 59 | @echo "$(OK_COLOR)==> Exported container calls in container.go $(NO_COLOR)" |
| 60 | @/bin/grep -E "\bc+\.([A-Z])\w+" container.go || true |
| 61 | |
| 62 | .PHONY: all format test doc vet lint ctags |