Skip to content

Commit 9d91339

Browse files
committed
initial
1 parent 56796fc commit 9d91339

File tree

11 files changed

+1133
-0
lines changed

11 files changed

+1133
-0
lines changed

.golangci.yml

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
run:
2+
timeout: 5m
3+
4+
linters-settings:
5+
dupl:
6+
threshold: 100
7+
exhaustive:
8+
default-signifies-exhaustive: false
9+
funlen:
10+
lines: 100
11+
statements: 50
12+
gci:
13+
sections:
14+
- standard
15+
- default
16+
- localmodule
17+
goconst:
18+
min-len: 3
19+
min-occurrences: 3
20+
gocritic:
21+
enabled-tags:
22+
- diagnostic
23+
- experimental
24+
- opinionated
25+
- performance
26+
- style
27+
disabled-checks:
28+
- dupImport
29+
- ifElseChain
30+
- octalLiteral
31+
- whyNoLint
32+
- wrapperFunc
33+
gocyclo:
34+
min-complexity: 15
35+
gocognit:
36+
min-complexity: 30
37+
goimports:
38+
local-prefixes: github.com/golangci/golangci-lint
39+
mnd:
40+
checks:
41+
- argument
42+
- case
43+
- condition
44+
- return
45+
ignored-numbers:
46+
- '0'
47+
- '1'
48+
- '2'
49+
- '5'
50+
- '10'
51+
- '50'
52+
- '100'
53+
- '1000'
54+
govet:
55+
enable:
56+
- shadow
57+
settings:
58+
printf:
59+
funcs:
60+
- (gofr.dev/pkg/gofr/Logger).Logf
61+
- (gofr.dev/pkg/gofr/Logger).Errorf
62+
lll:
63+
line-length: 140
64+
misspell:
65+
locale: US
66+
nestif:
67+
min-complexity: 6
68+
nolintlint:
69+
allow-unused: false
70+
require-explanation: true
71+
require-specific: true
72+
revive:
73+
severity: warning
74+
confidence: 0.8
75+
rules:
76+
- name: blank-imports
77+
- name: context-as-argument
78+
- name: context-keys-type
79+
- name: dot-imports
80+
- name: empty-block
81+
- name: error-naming
82+
- name: error-return
83+
- name: error-strings
84+
- name: errorf
85+
- name: increment-decrement
86+
- name: indent-error-flow
87+
- name: range
88+
- name: receiver-naming
89+
- name: redefines-builtin-id
90+
- name: superfluous-else
91+
- name: time-naming
92+
- name: unexported-return
93+
- name: unreachable-code
94+
- name: unused-parameter
95+
- name: var-declaration
96+
- name: var-naming
97+
- name: bare-return
98+
- name: bool-literal-in-expr
99+
- name: comment-spacings
100+
- name: early-return
101+
- name: defer
102+
- name: deep-exit
103+
- name: unused-receiver
104+
# Disable the exported rule to avoid stuttering complaints
105+
- name: exported
106+
disabled: true
107+
108+
linters:
109+
disable-all: true
110+
enable:
111+
- asciicheck
112+
- bodyclose
113+
- dogsled
114+
- dupl
115+
- err113
116+
- errcheck
117+
- errorlint
118+
- exhaustive
119+
- copyloopvar
120+
- funlen
121+
- gochecknoglobals
122+
- gochecknoinits
123+
- gocognit
124+
- goconst
125+
- gocritic
126+
- gocyclo
127+
- gofmt
128+
- goimports
129+
- goprintffuncname
130+
- gosec
131+
- gosimple
132+
- govet
133+
- ineffassign
134+
- lll
135+
- mirror
136+
- misspell
137+
- mnd
138+
- nakedret
139+
- nestif
140+
- noctx
141+
- nolintlint
142+
- prealloc
143+
- revive
144+
- rowserrcheck
145+
- staticcheck
146+
- stylecheck
147+
- testifylint
148+
- thelper
149+
- unconvert
150+
- unparam
151+
- unused
152+
- usestdlibvars
153+
- whitespace
154+
- wsl
155+
156+
issues:
157+
exclude-dirs:
158+
- proto/flow
159+
exclude-rules:
160+
# Very permissive for test files
161+
- path: _test\.go
162+
linters:
163+
- mnd
164+
- dupl
165+
- goconst
166+
- funlen
167+
- gocognit
168+
- gocyclo
169+
- err113
170+
- noctx
171+
- gocritic
172+
- errcheck
173+
- ineffassign
174+
- gochecknoglobals
175+
- gochecknoinits
176+
# Specific file exclusions
177+
- path: pkg/core/api/server\.go
178+
linters:
179+
- typecheck
180+
# Exclude common magic numbers everywhere
181+
- linters:
182+
- mnd
183+
text: "Magic number: (25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9]),"
184+
# Exclude revive exported/stuttering complaints
185+
- linters:
186+
- revive
187+
text: "(exported|stutters)"
188+
# Exclude err113 for common patterns
189+
- linters:
190+
- err113
191+
text: "(do not define dynamic errors|errors.New)"
192+
# Exclude gosec weak random
193+
- linters:
194+
- gosec
195+
text: "G404:"
196+
# More permissive with interfaces
197+
- linters:
198+
- stylecheck
199+
text: "ST1003:"

.idea/.gitignore

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/bmssp-go.iml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Go configuration
2+
GO ?= go
3+
GOBIN ?= $$($(GO) env GOPATH)/bin
4+
GOLANGCI_LINT ?= $(GOBIN)/golangci-lint
5+
GOLANGCI_LINT_VERSION ?= v2.0.2
6+
7+
# Colors for pretty printing
8+
COLOR_RESET = \033[0m
9+
COLOR_BOLD = \033[1m
10+
COLOR_GREEN = \033[32m
11+
COLOR_YELLOW = \033[33m
12+
COLOR_CYAN = \033[36m
13+
14+
.PHONY: help
15+
help: ## Show this help message
16+
@echo "$(COLOR_BOLD)Available targets:$(COLOR_RESET)"
17+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " $(COLOR_CYAN)%-20s$(COLOR_RESET) %s\n", $$1, $$2}'
18+
19+
.PHONY: tidy
20+
tidy: ## Tidy and format Go code
21+
@echo "$(COLOR_BOLD)Tidying Go modules and formatting code$(COLOR_RESET)"
22+
@$(GO) mod tidy
23+
@$(GO) fmt ./...
24+
25+
.PHONY: get-golangcilint
26+
get-golangcilint: ## Install golangci-lint
27+
@echo "$(COLOR_BOLD)Installing golangci-lint $(GOLANGCI_LINT_VERSION)$(COLOR_RESET)"
28+
@test -f $(GOLANGCI_LINT) || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$($(GO) env GOPATH)/bin $(GOLANGCI_LINT_VERSION)
29+
30+
.PHONY: lint
31+
lint: get-golangcilint ## Run linting checks
32+
@echo "$(COLOR_BOLD)Running Go linter$(COLOR_RESET)"
33+
@$(GOLANGCI_LINT) run ./...
34+
35+
.PHONY: test
36+
test: ## Run all tests with coverage
37+
@echo "$(COLOR_BOLD)Running Go short tests$(COLOR_RESET)"
38+
@$(GO) test -timeout=3s -race -count=10 -failfast -shuffle=on -short ./... -coverprofile=./cover.short.profile -covermode=atomic -coverpkg=./...
39+
@echo "$(COLOR_BOLD)Running Go long tests$(COLOR_RESET)"
40+
@$(GO) test -timeout=10s -race -count=1 -failfast -shuffle=on ./... -coverprofile=./cover.long.profile -covermode=atomic -coverpkg=./...
41+
42+
.PHONY: check-coverage
43+
check-coverage: test ## Check test coverage against thresholds
44+
@echo "$(COLOR_BOLD)Checking test coverage$(COLOR_RESET)"
45+
@$(GO) run ./main.go --config=./.github/.testcoverage.yml
46+
47+
.PHONY: view-coverage
48+
view-coverage: ## Generate and view coverage report
49+
@echo "$(COLOR_BOLD)Generating coverage report$(COLOR_RESET)"
50+
@$(GO) test ./... -coverprofile=./cover.all.profile -covermode=atomic -coverpkg=./...
51+
@$(GO) tool cover -html=cover.all.profile -o=cover.html
52+
@xdg-open cover.html
53+
54+
.PHONY: clean
55+
clean: ## Clean up build artifacts
56+
@echo "$(COLOR_BOLD)Cleaning up build artifacts$(COLOR_RESET)"
57+
@rm -f cover.*.profile cover.html
58+
59+
# Default target
60+
.DEFAULT_GOAL := help

0 commit comments

Comments
 (0)