Skip to content
Draft
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
16 changes: 11 additions & 5 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,28 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- name: Setup Go
uses: actions/setup-go@v5
uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
- name: Install dependencies
run: go mod vendor
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v4
uses: golangci/golangci-lint-action@v8
with:
version: latest
version: v2.6.1
args: --timeout=5m
only-new-issues: false
- name: Test with Go
run: go test -json > TestResults.json
run: |
set +e
go test -tags=examples -json ./... > TestResults.json
TEST_EXIT_CODE=$?
exit $TEST_EXIT_CODE
- name: Upload Go test results
uses: actions/upload-artifact@v4
if: always()
with:
name: Go-results
path: TestResults.json
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Coverage reports
coverage.out
coverage.html

# Test output and profiling
*.log
*.prof

# Dependency directories (remove the comment below to include it)
# vendor/

Expand Down
251 changes: 131 additions & 120 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,46 @@
# golangci-lint configuration
# Documentation: https://golangci-lint.run/usage/configuration/
version: "2"

run:
timeout: 5m
tests: true
modules-download-mode: readonly
build-tags:
- examples

# Output configuration
output:
formats:
- format: colored-line-number
print-issued-lines: true
print-linter-name: true
sort-results: true
formatters:
enable:
- gofmt # Checks whether code was gofmt-ed
- goimports # Check import statements are formatted according to goimport command
- gci # Controls Go package import order and makes it deterministic

settings:
gofmt:
# Simplify code: gofmt with `-s` option
simplify: true

goimports:
# Use goimports as the formatter
local-prefixes:
- github.com/dcbickfo/redcache

gci:
# Section configuration to compare against
sections:
- standard # Standard section: captures all standard packages
- default # Default section: contains all imports that could not be matched to another section type
- prefix(github.com/dcbickfo/redcache) # Custom section: groups all imports with the specified Prefix

linters:
disable-all: true
default: none
enable:
# Enabled by default
- errcheck # Checks for unchecked errors
- gosimple # Simplify code
- govet # Reports suspicious constructs
- ineffassign # Detects ineffectual assignments
- staticcheck # Staticcheck is a go vet on steroids
- staticcheck # Staticcheck is a go vet on steroids (includes gosimple)
- unused # Checks for unused constants, variables, functions and types

# Additional recommended linters
- gofmt # Checks whether code was gofmt-ed
- goimports # Check import statements are formatted according to goimport command
- misspell # Finds commonly misspelled English words
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go
- gocyclo # Computes cyclomatic complexities
Expand All @@ -39,116 +52,114 @@ linters:
- gocognit # Computes cognitive complexities
- godot # Check if comments end in a period
- whitespace # Detection of leading and trailing whitespace
- gci # Controls Go package import order and makes it deterministic

linters-settings:
goimports:
# Use goimports as the formatter
local-prefixes: github.com/dcbickfo/redcache

gofmt:
# Simplify code: gofmt with `-s` option
simplify: true

gocyclo:
# Minimal cyclomatic complexity to report
min-complexity: 15

gocognit:
# Minimal cognitive complexity to report
min-complexity: 15

goconst:
# Minimal length of string constant
min-len: 3
# Minimum occurrences to report
min-occurrences: 3

gosec:
# Exclude some checks
excludes:
- G104 # Audit errors not checked (we use errcheck for this)

revive:
confidence: 0.8
settings:
govet:
# Enable shadow checking
enable:
- shadow
settings:
shadow:
strict: true

gocyclo:
# Minimal cyclomatic complexity to report
min-complexity: 15

gocognit:
# Minimal cognitive complexity to report
min-complexity: 15

goconst:
# Minimal length of string constant
min-len: 3
# Minimum occurrences to report
min-occurrences: 3

gosec:
# Exclude some checks
excludes:
- G104 # Audit errors not checked (we use errcheck for this)

revive:
confidence: 0.8
rules:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: exported
- name: if-return
- name: increment-decrement
- name: var-naming
- name: var-declaration
- name: package-comments
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
- name: empty-block
- name: superfluous-else
- name: unused-parameter
- name: unreachable-code
- name: redefines-builtin-id

nakedret:
# Make an issue if func has more lines of code than this setting and has naked return
max-func-lines: 30

unparam:
check-exported: true

whitespace:
multi-if: false
multi-func: false

exclusions:
# Excluding configuration per-path, per-linter, per-text and per-source
rules:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: exported
- name: if-return
- name: increment-decrement
- name: var-naming
- name: var-declaration
- name: package-comments
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
- name: empty-block
- name: superfluous-else
- name: unused-parameter
- name: unreachable-code
- name: redefines-builtin-id

nakedret:
# Make an issue if func has more lines of code than this setting and has naked return
max-func-lines: 30

unparam:
# Check exported functions
check-exported: false

whitespace:
multi-if: false
multi-func: false

gci:
# Section configuration to compare against
sections:
- standard # Standard section: captures all standard packages
- default # Default section: contains all imports that could not be matched to another section type
- prefix(github.com/dcbickfo/redcache) # Custom section: groups all imports with the specified Prefix
# Exclude some linters from running on tests files
- path: _test\.go
linters:
- gocyclo
- gocognit
- errcheck
- gosec
- unparam
- revive
- goconst
- godot
- whitespace

# Exclude some linters from running on example files
- path: examples/
linters:
- gocyclo
- gocognit
- errcheck
- gosec
- unparam
- revive
- goconst
- godot
- govet

# Exclude documentation requirements for internal packages
- path: internal/
linters:
- revive

# Exclude vendor
- path: vendor/
linters:
- all

issues:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
# Exclude some linters from running on tests files
- path: _test\.go
linters:
- gocyclo
- gocognit
- errcheck
- gosec
- unparam
- revive
- goconst
- godot
- whitespace
- gci

# Exclude known issues in vendor
- path: vendor/
linters:
- all

# Ignore "new" parameter name shadowing built-in
- text: "redefines-builtin-id"
linters:
- revive

# Ignore integer overflow in CRC16 - this is intentional and safe
- text: "G115.*integer overflow"
path: internal/cmdx/slot.go
linters:
- gosec

# Maximum issues count per one linter
max-issues-per-linter: 50

Expand Down
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
golang 1.25.3
golangci-lint 2.6.1
Loading
Loading