chore: bump Go to 1.26.1 and golangci-lint to v2.11.2; fix typos and lint nolints

This commit is contained in:
2026-03-10 02:32:40 +04:00
parent 844f139a10
commit 026d05f1bf
12 changed files with 23 additions and 24 deletions

View File

@@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v5 - uses: actions/checkout@v5
- uses: actions/setup-go@v6 - uses: actions/setup-go@v6
with: with:
go-version: 1.26.0 go-version: 1.26.1
- name: go fix - name: go fix
run: | run: |
go fix ./... go fix ./...
@@ -24,4 +24,4 @@ jobs:
- name: golangci-lint - name: golangci-lint
uses: golangci/golangci-lint-action@v9 uses: golangci/golangci-lint-action@v9
with: with:
version: v2.9.0 version: v2.11.2

View File

@@ -35,7 +35,7 @@ jobs:
run: | run: |
echo "VERSION=$(git describe --tags --always)" >> $GITHUB_ENV echo "VERSION=$(git describe --tags --always)" >> $GITHUB_ENV
echo "GIT_COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENV echo "GIT_COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENV
echo "GO_VERSION=1.26.0" >> $GITHUB_ENV echo "GO_VERSION=1.26.1" >> $GITHUB_ENV
- name: Set up Go - name: Set up Go
if: github.event_name == 'release' || inputs.build_binaries if: github.event_name == 'release' || inputs.build_binaries

View File

@@ -1,4 +1,4 @@
ARG GO_VERSION=1.26.0 ARG GO_VERSION=1.26.1
FROM docker.io/library/golang:${GO_VERSION}-alpine AS builder FROM docker.io/library/golang:${GO_VERSION}-alpine AS builder

View File

@@ -3,7 +3,7 @@ version: "3"
vars: vars:
BIN_DIR: ./bin BIN_DIR: ./bin
GOLANGCI_LINT_VERSION: v2.9.0 GOLANGCI_LINT_VERSION: v2.11.2
GOLANGCI: "{{.BIN_DIR}}/golangci-lint-{{.GOLANGCI_LINT_VERSION}}" GOLANGCI: "{{.BIN_DIR}}/golangci-lint-{{.GOLANGCI_LINT_VERSION}}"
tasks: tasks:

View File

@@ -14,7 +14,7 @@ import (
) )
func main() { func main() {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background()) //nolint:gosec // G118: cancel is called in listenForTermination goroutine
go listenForTermination(func() { cancel() }) go listenForTermination(func() { cancel() })
combinedConfig := config.ReadAllConfigs() combinedConfig := config.ReadAllConfigs()

2
go.mod
View File

@@ -1,6 +1,6 @@
module go.aykhans.me/sarin module go.aykhans.me/sarin
go 1.26.0 go 1.26.1
require ( require (
github.com/brianvoe/gofakeit/v7 v7.14.1 github.com/brianvoe/gofakeit/v7 v7.14.1

View File

@@ -418,7 +418,7 @@ func (config Config) Validate() error {
validationErrors = append(validationErrors, types.NewFieldValidationError("Duration", "0", errors.New("duration must be greater than 0"))) validationErrors = append(validationErrors, types.NewFieldValidationError("Duration", "0", errors.New("duration must be greater than 0")))
} }
if *config.Timeout < 1 { if config.Timeout == nil || *config.Timeout < 1 {
validationErrors = append(validationErrors, types.NewFieldValidationError("Timeout", "0", errors.New("timeout must be greater than 0"))) validationErrors = append(validationErrors, types.NewFieldValidationError("Timeout", "0", errors.New("timeout must be greater than 0")))
} }

View File

@@ -157,7 +157,7 @@ func (parser ConfigENVParser) Parse() (*Config, error) {
types.NewFieldParseError( types.NewFieldParseError(
parser.getFullEnvName("DURATION"), parser.getFullEnvName("DURATION"),
duration, duration,
errors.New("invalid value duration, expected a duration string (e.g., '10s', '1h30m')"), errors.New("invalid value for duration, expected a duration string (e.g., '10s', '1h30m')"),
), ),
) )
} else { } else {
@@ -173,7 +173,7 @@ func (parser ConfigENVParser) Parse() (*Config, error) {
types.NewFieldParseError( types.NewFieldParseError(
parser.getFullEnvName("TIMEOUT"), parser.getFullEnvName("TIMEOUT"),
timeout, timeout,
errors.New("invalid value duration, expected a duration string (e.g., '10s', '1h30m')"), errors.New("invalid value for duration, expected a duration string (e.g., '10s', '1h30m')"),
), ),
) )
} else { } else {

View File

@@ -172,7 +172,6 @@ func fasthttpSocksDialerDualStackTimeout(ctx context.Context, proxyURL *url.URL,
return nil, types.NewProxyDialError(proxyStr, err) return nil, types.NewProxyDialError(proxyStr, err)
} }
// Cap DNS resolution to half the timeout to reserve time for dial
dnsCtx, dnsCancel := context.WithTimeout(ctx, timeout) dnsCtx, dnsCancel := context.WithTimeout(ctx, timeout)
ips, err := net.DefaultResolver.LookupIP(dnsCtx, "ip", host) ips, err := net.DefaultResolver.LookupIP(dnsCtx, "ip", host)
dnsCancel() dnsCancel()
@@ -244,7 +243,7 @@ func fasthttpHTTPSDialerDualStackTimeout(proxyURL *url.URL, timeout time.Duratio
} }
// Upgrade to TLS // Upgrade to TLS
tlsConn := tls.Client(conn, &tls.Config{ //nolint:gosec tlsConn := tls.Client(conn, &tls.Config{
ServerName: proxyURL.Hostname(), ServerName: proxyURL.Hostname(),
}) })
if err := tlsConn.Handshake(); err != nil { if err := tlsConn.Handshake(); err != nil {

View File

@@ -8,7 +8,7 @@ import (
func NewDefaultRandSource() rand.Source { func NewDefaultRandSource() rand.Source {
now := time.Now().UnixNano() now := time.Now().UnixNano()
return rand.NewPCG( return rand.NewPCG(
uint64(now), //nolint:gosec // G115: Safe conversion; UnixNano timestamp used as random seed, bit pattern is intentional uint64(now),
uint64(now>>32), //nolint:gosec // G115: Safe conversion; right-shifted timestamp for seed entropy, overflow is acceptable uint64(now>>32),
) )
} }

View File

@@ -91,7 +91,7 @@ func NewRequestGenerator(
return err return err
} }
bodyTemplateFuncMapData.ClearFormDataContenType() bodyTemplateFuncMapData.ClearFormDataContentType()
if err = bodyGenerator(reqData, data); err != nil { if err = bodyGenerator(reqData, data); err != nil {
return err return err
} }
@@ -99,8 +99,8 @@ func NewRequestGenerator(
if err = headersGenerator(reqData, data); err != nil { if err = headersGenerator(reqData, data); err != nil {
return err return err
} }
if bodyTemplateFuncMapData.GetFormDataContenType() != "" { if bodyTemplateFuncMapData.GetFormDataContentType() != "" {
reqData.Headers["Content-Type"] = append(reqData.Headers["Content-Type"], bodyTemplateFuncMapData.GetFormDataContenType()) reqData.Headers["Content-Type"] = append(reqData.Headers["Content-Type"], bodyTemplateFuncMapData.GetFormDataContentType())
} }
if err = paramsGenerator(reqData, data); err != nil { if err = paramsGenerator(reqData, data); err != nil {

View File

@@ -286,7 +286,7 @@ func NewDefaultTemplateFuncMap(randSource rand.Source, fileCache *FileCache) tem
"fakeit_AdverbFrequencyDefinite": fakeit.AdverbFrequencyDefinite, "fakeit_AdverbFrequencyDefinite": fakeit.AdverbFrequencyDefinite,
"fakeit_AdverbFrequencyIndefinite": fakeit.AdverbFrequencyIndefinite, "fakeit_AdverbFrequencyIndefinite": fakeit.AdverbFrequencyIndefinite,
// Propositions // Prepositions
"fakeit_Preposition": fakeit.Preposition, "fakeit_Preposition": fakeit.Preposition,
"fakeit_PrepositionSimple": fakeit.PrepositionSimple, "fakeit_PrepositionSimple": fakeit.PrepositionSimple,
"fakeit_PrepositionDouble": fakeit.PrepositionDouble, "fakeit_PrepositionDouble": fakeit.PrepositionDouble,
@@ -589,15 +589,15 @@ func NewDefaultTemplateFuncMap(randSource rand.Source, fileCache *FileCache) tem
} }
type BodyTemplateFuncMapData struct { type BodyTemplateFuncMapData struct {
formDataContenType string formDataContentType string
} }
func (data BodyTemplateFuncMapData) GetFormDataContenType() string { func (data BodyTemplateFuncMapData) GetFormDataContentType() string {
return data.formDataContenType return data.formDataContentType
} }
func (data *BodyTemplateFuncMapData) ClearFormDataContenType() { func (data *BodyTemplateFuncMapData) ClearFormDataContentType() {
data.formDataContenType = "" data.formDataContentType = ""
} }
func NewDefaultBodyTemplateFuncMap( func NewDefaultBodyTemplateFuncMap(
@@ -628,7 +628,7 @@ func NewDefaultBodyTemplateFuncMap(
var multipartData bytes.Buffer var multipartData bytes.Buffer
writer := multipart.NewWriter(&multipartData) writer := multipart.NewWriter(&multipartData)
data.formDataContenType = writer.FormDataContentType() data.formDataContentType = writer.FormDataContentType()
for i := 0; i < len(pairs); i += 2 { for i := 0; i < len(pairs); i += 2 {
key := pairs[i] key := pairs[i]