Skip to content

Commit fec0d33

Browse files
committed
HYPERFLEET-930 - chore: add gci linter
1 parent c1791af commit fec0d33

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

.golangci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,18 @@ formatters:
8787
enable:
8888
- gofmt
8989
- goimports
90+
- gci
9091
settings:
9192
gofmt:
9293
simplify: true
94+
# Local addition on top of org standard: repo-specific import grouping
95+
gci:
96+
custom-order: true
97+
sections:
98+
- standard
99+
- default
100+
- prefix(github.com/openshift-hyperfleet)
101+
- prefix(github.com/openshift-hyperfleet/hyperfleet-sentinel)
93102
exclusions:
94103
generated: lax
95104
paths:

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ include .bingo/Variables.mk
33
.DEFAULT_GOAL := help
44

55
GO ?= go
6-
GOFMT ?= gofmt
76

87
# Schema variant for OpenAPI generation (core, gcp)
98
VARIANT ?= core
@@ -113,18 +112,19 @@ test-coverage: test ## Run tests and show coverage
113112
##@ Code Quality
114113

115114
.PHONY: fmt
116-
fmt: ## Format Go code
117-
$(GOFMT) -s -w .
115+
fmt: ## Format Go code and imports
116+
$(GOLANGCI_LINT) fmt ./...
118117

119118
.PHONY: gofmt
120119
gofmt: fmt ## Alias for fmt
121120

122121
.PHONY: fmt-check
123122
fmt-check: ## Check if code is formatted
124-
@diff=$$($(GOFMT) -s -d .); \
123+
@diff=$$($(GOLANGCI_LINT) fmt --diff ./... 2>&1) || { echo "$$diff"; echo "golangci-lint fmt failed"; exit 1; }; \
125124
if [ -n "$$diff" ]; then \
126-
echo "Code is not formatted. Run 'make fmt' to fix:"; \
127-
echo "$$diff"; \
125+
echo "$$diff" >&2; \
126+
echo ""; \
127+
echo "Code is not formatted. Run 'make fmt' to fix."; \
128128
exit 1; \
129129
fi
130130

0 commit comments

Comments
 (0)