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
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
cache-dependency-path: go.sum
go-version-file: go.mod
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/go_cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
build:
strategy:
matrix:
go-version: ["1.21.x", "1.22.x"]
go-version: ["1.26.x", "stable"]
arch: [x64, arm, arm64]
os: [macos-latest, ubuntu-latest] #windows-latest

Expand Down Expand Up @@ -45,15 +45,15 @@ jobs:
- name: Fetch latest changes
run: git fetch --all
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
check-latest: true

# - name: Clear Go cache
# run: go clean -cache
- name: Cache Go tests
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
${{env.GOCACHE}}
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/go_fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ jobs:
timeout-minutes: 8

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: 1.20.4
go-version-file: go.mod
check-latest: true
cache-dependency-path: go.sum

Expand Down Expand Up @@ -82,12 +82,12 @@ jobs:
packages: none

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# - name: Set up Go
# uses: actions/setup-go@v4
# uses: actions/setup-go@v5
# with:
# go-version: 1.20.4
# go-version-file: go.mod
# check-latest: true
#
# - name: Go Generate #Artifacts are not reliable
Expand Down
242 changes: 112 additions & 130 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,156 +1,138 @@
linters-settings:
dupl:
threshold: 100
funlen:
lines: 100
statements: 50
goconst:
min-len: 2
min-occurrences: 3
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- dupImport # https://github.com/go-critic/go-critic/issues/845
- ifElseChain
- octalLiteral
- whyNoLint
- wrapperFunc
gocyclo:
min-complexity: 15
goimports:
local-prefixes: github.com/golangci/golangci-lint
mnd:
# don't include the "operation" and "assign"
checks:
- argument
- case
- condition
- return
ignored-numbers:
- "0"
- "1"
- "2"
- "3"
ignored-functions:
- strings.SplitN

lll:
line-length: 140
misspell:
locale: US
nolintlint:
allow-unused: false # report any unused nolint directives
require-explanation: false # don't require an explanation for nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped

version: "2"
run:
go: "1.26"
linters:
# Disable all linters.
# Default: false
disable-all: true
# Enable specific linter
# https://golangci-lint.run/usage/linters/#enabled-by-default-linters
default: none
enable:
- asciicheck
- bodyclose
# - deadcode #deprecated
- depguard
- dogsled
- dupl
- errcheck
- exportloopref
- funlen
- gochecknoinits
- goconst
- gocritic
- gocyclo
- gofmt
- goimports
- mnd
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- lll
- misspell
- mnd
- nakedret
- noctx
- nolintlint
- revive
- staticcheck
# - structcheck #deprecated
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- revive
# - varcheck #deprecated
- whitespace

# don't enable:
# - asciicheck
# - scopelint
# - gochecknoglobals
# - gocognit
# - godot
# - godox
# - goerr113
# - interfacer
# - maligned
# - nestif
# - prealloc
# - testpackage
# - revive
# - wsl

issues:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
- path: _test\.go
linters:
- gomnd
- revive
- depguard
- path: db_test.go
text: "deferInLoop: Possible resource leak, 'defer' is called in the 'for' loop"

- path: \.go
text: "commentedOutCode: may want to remove commented-out code"

- path: \.go
text: "commentFormatting: put a space between `//` and comment text"

- path: _test.go
linters:
- whitespace
text: "unnecessary (leading|trailing) newline"

- path: db_test.go
linters:
- goconst
- funlen
- gocyclo
- errcheck
- gocritic
- govet

- path: fuzz_test.go
linters:
- goconst
- funlen
- gocyclo
- errcheck
- gocritic
- govet

- path: \.go
text: "G404: Use of weak random number generator" #expected, just for randomLB policy

run:
timeout: 5m
go: "1.22"
settings:
dupl:
threshold: 100
funlen:
lines: 100
statements: 50
goconst:
min-len: 2
min-occurrences: 3
gocritic:
disabled-checks:
- dupImport
- ifElseChain
- octalLiteral
- whyNoLint
- wrapperFunc
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
gocyclo:
min-complexity: 15
lll:
line-length: 140
misspell:
locale: US
mnd:
checks:
- argument
- case
- condition
- return
ignored-numbers:
- "0"
- "1"
- "2"
- "3"
ignored-functions:
- strings.SplitN
nolintlint:
require-explanation: false
require-specific: false
allow-unused: false
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- mnd
- revive
path: _test\.go
- path: db_test.go
text: 'deferInLoop: Possible resource leak, ''defer'' is called in the ''for'' loop'
- path: \.go
text: 'commentedOutCode: may want to remove commented-out code'
- path: \.go
text: 'commentFormatting: put a space between `//` and comment text'
- linters:
- whitespace
path: _test.go
text: unnecessary (leading|trailing) newline
- linters:
- errcheck
- funlen
- goconst
- gocritic
- gocyclo
- govet
path: db_test.go
- linters:
- errcheck
- funlen
- goconst
- gocritic
- gocyclo
- govet
path: fuzz_test.go
- path: \.go
text: 'G404: Use of weak random number generator'
- path: \.go
# modulo by an element count is bounded and always fits the target type
text: 'G115: integer overflow conversion'
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
- goimports
settings:
goimports:
local-prefixes:
- github.com/golangci/golangci-lint
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
16 changes: 8 additions & 8 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import (
type Conn interface {
Close() error
BeginTx(ctx context.Context, opts *sql.TxOptions) (Tx, error)
ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
PingContext(ctx context.Context) error
PrepareContext(ctx context.Context, query string) (Stmt, error)
QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
Raw(f func(driverConn interface{}) error) (err error)
QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
Raw(f func(driverConn any) error) (err error)
}

type conn struct {
Expand All @@ -40,7 +40,7 @@ func (c *conn) BeginTx(ctx context.Context, opts *sql.TxOptions) (Tx, error) {
}, nil
}

func (c *conn) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) {
func (c *conn) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) {
return c.conn.ExecContext(ctx, query, args...)
}

Expand All @@ -60,14 +60,14 @@ func (c *conn) PrepareContext(ctx context.Context, query string) (Stmt, error) {
return newSingleDBStmt(c.sourceDB, pstmt, writeFlag), nil
}

func (c *conn) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) {
func (c *conn) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error) {
return c.conn.QueryContext(ctx, query, args...)
}

func (c *conn) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row {
func (c *conn) QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row {
return c.conn.QueryRowContext(ctx, query, args...)
}

func (c *conn) Raw(f func(driverConn interface{}) error) (err error) {
func (c *conn) Raw(f func(driverConn any) error) (err error) {
return c.conn.Raw(f)
}
Loading
Loading