-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
69 lines (57 loc) · 1.76 KB
/
Makefile
File metadata and controls
69 lines (57 loc) · 1.76 KB
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
# SPDX-License-Identifier: Apache-2.0
#
# Copyright (c) nexB Inc. and others. All rights reserved.
# ScanCode is a trademark of nexB Inc.
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# See https://github.com/aboutcode-org/purl-validator-go for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#
GOCMD=go
GOFMT=gofmt
GOIMPORTS=goimports
GOLINT=golangci-lint
GOFMT_CMD = $(GOFMT) -l .
GOIMPORTS_CMD = $(GOIMPORTS) -l .
GOSEC=gosec
build-fst:
go run ./cmd/main.go
clean:
$(GOCMD) clean
rm -rf $(BUILD_DIR)
test:
$(GOCMD) test -v
dev:
$(GOCMD) install golang.org/x/tools/cmd/goimports@latest
$(GOCMD) install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
$(GOCMD) install github.com/securego/gosec/v2/cmd/gosec@latest
$(GOCMD) mod tidy
gofmt:
@echo "-> Apply gofmt code formatter"
$(GOFMT) -w .
goimports:
@echo "-> Apply goimports changes to ensure proper imports ordering"
$(GOIMPORTS) -w .
valid: goimports gofmt
check-gofmt:
@echo "-> Running gofmt for code formatting validation..."
@files=$$($(GOFMT_CMD)); \
if [ -n "$$files" ]; then \
echo "The following files are not properly formatted:"; \
echo "$$files"; \
exit 1; \
fi
check-goimports:
@echo "-> Running goimports for import ordering validation..."
@files=$$($(GOIMPORTS_CMD)); \
if [ -n "$$files" ]; then \
echo "The following files have incorrect imports:"; \
echo "$$files"; \
exit 1; \
fi
check: check-gofmt check-goimports
@echo "\n-> Running golangci-lint for linting..."
$(GOLINT) run --issues-exit-code=1 ./...
@echo "\n-> Running gosec for security checks..."
$(GOSEC) ./...
.PHONY: build-fst clean test dev gofmt goimports valid check-gofmt check-goimports check