Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@ jobs:
with:
go-version-file: go.mod
check-latest: true
- name: Setup golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.12
args: --verbose
- name: Run lint
run: make install-tools lint
test:
strategy:
matrix:
Expand Down
127 changes: 91 additions & 36 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,69 +1,124 @@
version: "2"
output:
sort-order:
- file
linters:
default: none
enable:
- bidichk
- bodyclose
- depguard
- dogsled
- dupl
- errcheck
- exhaustive
- gochecknoinits
- goconst
- forbidigo
- gocheckcompilerdirectives
- gocritic
- gocyclo
- goprintffuncname
- gosec
- govet
- ineffassign
- lll
- misspell
- mirror
- modernize
- nakedret
- noctx
- nilnil
- nolintlint
- rowserrcheck
- perfsprint
- revive
- staticcheck
- testifylint
- unconvert
- unparam
- unused
- whitespace
- usestdlibvars
- usetesting
- wastedassign
settings:
depguard:
rules:
Main:
files:
- $all
- "!$test"
allow:
- $gostd
- github.com/gin-gonic/gin
Test:
files:
- $test
allow:
- $gostd
- github.com/gin-gonic/gin
- github.com/stretchr/testify
main:
deny:
- pkg: io/ioutil
desc: use os or io instead
- pkg: golang.org/x/exp
desc: it's experimental and unreliable
- pkg: github.com/pkg/errors
desc: use builtin errors package instead
nolintlint:
allow-unused: false
require-explanation: true
require-specific: true
gocritic:
enabled-checks:
- equalFold
disabled-checks: []
revive:
severity: error
rules:
- name: blank-imports
- name: constant-logical-expr
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: empty-lines
- name: error-return
- name: error-strings
- name: exported
- name: identical-branches
- name: if-return
- name: increment-decrement
- name: modifies-value-receiver
- name: package-comments
- name: redefines-builtin-id
- name: superfluous-else
- name: time-naming
- name: unexported-return
- name: var-declaration
- name: var-naming
disabled: true
staticcheck:
checks:
- all
testifylint: {}
usetesting:
os-temp-dir: true
perfsprint:
concat-loop: false
govet:
enable:
- nilness
- unusedwrite
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
rules:
- linters:
- errcheck
- staticcheck
- unparam
path: _test\.go
issues:
max-issues-per-linter: 0
max-same-issues: 0
formatters:
enable:
- gci
- gofmt
- gofumpt
- goimports
- golines
settings:
gci:
custom-order: true
sections:
- standard
- prefix(github.com/gin-contrib/timeout)
- default
gofumpt:
extra:
group-params: true
clothe-returns: true
balance-calls: true
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
run:
timeout: 10m
40 changes: 40 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
GO ?= go
TOOLS_MOD := -modfile=go.tools.mod

## lint: run golangci-lint to check for issues
lint:
$(GO) tool $(TOOLS_MOD) golangci-lint run

## fmt: format go files using golangci-lint
fmt:
$(GO) tool $(TOOLS_MOD) golangci-lint fmt

## test: run tests
test:
$(GO) test -v -cover -coverprofile=coverage.txt ./... && echo "\n==>\033[32m Ok\033[m\n" || exit 1

## coverage: view test coverage in browser
coverage: test
$(GO) tool cover -html=coverage.txt

## mod-download: download go module dependencies
mod-download:
$(GO) mod download

## mod-tidy: tidy go module dependencies
mod-tidy:
$(GO) mod tidy

## mod-verify: verify go module dependencies
mod-verify:
$(GO) mod verify

## install-tools: download tool dependencies
install-tools:
$(GO) mod download $(TOOLS_MOD)

## help: print this help message
help:
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'

.PHONY: lint fmt test coverage mod-download mod-tidy mod-verify install-tools help
1 change: 1 addition & 0 deletions _example/example01/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

"github.com/gin-contrib/timeout"

"github.com/gin-gonic/gin"
)

Expand Down
1 change: 1 addition & 0 deletions _example/example02/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

"github.com/gin-contrib/timeout"

"github.com/gin-gonic/gin"
)

Expand Down
1 change: 1 addition & 0 deletions _example/example03/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

"github.com/gin-contrib/timeout"

"github.com/gin-gonic/gin"
)

Expand Down
1 change: 1 addition & 0 deletions _example/example04/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

"github.com/gin-contrib/timeout"

"github.com/gin-gonic/gin"
)

Expand Down
6 changes: 3 additions & 3 deletions buffer_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ func TestBufferPool_Concurrent(t *testing.T) {
var wg sync.WaitGroup
wg.Add(numGoroutines)

for i := 0; i < numGoroutines; i++ {
for range numGoroutines {
go func() {
defer wg.Done()
for j := 0; j < numGetsPerGoRoutine; j++ {
for range numGetsPerGoRoutine {
buf := pool.Get()
assert.NotNil(t, buf)
assert.Equal(t, 0, buf.Len(), "buffer should be empty")
Expand Down Expand Up @@ -62,7 +62,7 @@ func TestBufferPool_NoReset(t *testing.T) {

// After reset, buffer should be empty
buf.Reset()
assert.Equal(t, "", buf.String())
assert.Empty(t, buf.String())

pool.Put(buf)
buf2 := pool.Get()
Expand Down
Loading
Loading