mirror of
https://github.com/juanfont/headscale.git
synced 2026-03-30 14:12:37 +02:00
This commit upgrades the codebase from Go 1.25.5 to Go 1.26rc2 and adopts new language features. Toolchain updates: - go.mod: go 1.25.5 → go 1.26rc2 - flake.nix: buildGo125Module → buildGo126Module, go_1_25 → go_1_26 - flake.nix: build golangci-lint from source with Go 1.26 - Dockerfile.integration: golang:1.25-trixie → golang:1.26rc2-trixie - Dockerfile.tailscale-HEAD: golang:1.25-alpine → golang:1.26rc2-alpine - Dockerfile.derper: golang:alpine → golang:1.26rc2-alpine - .goreleaser.yml: go mod tidy -compat=1.25 → -compat=1.26 - cmd/hi/run.go: fallback Go version 1.25 → 1.26rc2 - .pre-commit-config.yaml: simplify golangci-lint hook entry Code modernization using Go 1.26 features: - Replace tsaddr.SortPrefixes with slices.SortFunc + netip.Prefix.Compare - Replace ptr.To(x) with new(x) syntax - Replace errors.As with errors.AsType[T] Lint rule updates: - Add forbidigo rules to prevent regression to old patterns
109 lines
2.7 KiB
YAML
109 lines
2.7 KiB
YAML
---
|
|
version: "2"
|
|
linters:
|
|
default: all
|
|
disable:
|
|
- cyclop
|
|
- depguard
|
|
- dupl
|
|
- exhaustruct
|
|
- funcorder
|
|
- funlen
|
|
- gochecknoglobals
|
|
- gochecknoinits
|
|
- gocognit
|
|
- godox
|
|
- interfacebloat
|
|
- ireturn
|
|
- lll
|
|
- maintidx
|
|
- makezero
|
|
- mnd
|
|
- musttag
|
|
- nestif
|
|
- nolintlint
|
|
- paralleltest
|
|
- revive
|
|
- tagliatelle
|
|
- testpackage
|
|
- varnamelen
|
|
- wrapcheck
|
|
- wsl
|
|
settings:
|
|
forbidigo:
|
|
forbid:
|
|
# Forbid time.Sleep everywhere with context-appropriate alternatives
|
|
- pattern: 'time\.Sleep'
|
|
msg: >-
|
|
time.Sleep is forbidden.
|
|
In tests: use assert.EventuallyWithT for polling/waiting patterns.
|
|
In production code: use a backoff strategy (e.g., cenkalti/backoff) or proper synchronization primitives.
|
|
# Forbid inline string literals in zerolog field methods - use zf.* constants
|
|
- pattern: '\.(Str|Int|Int8|Int16|Int32|Int64|Uint|Uint8|Uint16|Uint32|Uint64|Float32|Float64|Bool|Dur|Time|TimeDiff|Strs|Ints|Uints|Floats|Bools|Any|Interface)\("[^"]+"'
|
|
msg: >-
|
|
Use zf.* constants for zerolog field names instead of string literals.
|
|
Import "github.com/juanfont/headscale/hscontrol/util/zlog/zf" and use
|
|
constants like zf.NodeID, zf.UserName, etc. Add new constants to
|
|
hscontrol/util/zlog/zf/fields.go if needed.
|
|
# Forbid ptr.To - use Go 1.26 new(expr) instead
|
|
- pattern: 'ptr\.To\('
|
|
msg: >-
|
|
ptr.To is forbidden. Use Go 1.26's new(expr) syntax instead.
|
|
Example: ptr.To(value) → new(value)
|
|
# Forbid tsaddr.SortPrefixes - use slices.SortFunc with netip.Prefix.Compare
|
|
- pattern: 'tsaddr\.SortPrefixes'
|
|
msg: >-
|
|
tsaddr.SortPrefixes is forbidden. Use Go 1.26's netip.Prefix.Compare instead.
|
|
Example: slices.SortFunc(prefixes, netip.Prefix.Compare)
|
|
analyze-types: true
|
|
gocritic:
|
|
disabled-checks:
|
|
- appendAssign
|
|
- ifElseChain
|
|
nlreturn:
|
|
block-size: 4
|
|
varnamelen:
|
|
ignore-names:
|
|
- err
|
|
- db
|
|
- id
|
|
- ip
|
|
- ok
|
|
- c
|
|
- tt
|
|
- tx
|
|
- rx
|
|
- sb
|
|
- wg
|
|
- pr
|
|
- p
|
|
- p2
|
|
ignore-type-assert-ok: true
|
|
ignore-map-index-ok: true
|
|
exclusions:
|
|
generated: lax
|
|
presets:
|
|
- comments
|
|
- common-false-positives
|
|
- legacy
|
|
- std-error-handling
|
|
paths:
|
|
- third_party$
|
|
- builtin$
|
|
- examples$
|
|
- gen
|
|
|
|
formatters:
|
|
enable:
|
|
- gci
|
|
- gofmt
|
|
- gofumpt
|
|
- goimports
|
|
exclusions:
|
|
generated: lax
|
|
paths:
|
|
- third_party$
|
|
- builtin$
|
|
- examples$
|
|
- gen
|