Skip to content

Commit

Permalink
golangci-lint: enable fatcontext and canonicalheader
Browse files Browse the repository at this point in the history
- fatcontext prevents a problem we had in the past where you keep adding
  variables to a context
  canonicalheader has some performance improvements as it doesn't
  require go to canonize the header on each invocation

Those are the only new linters since last we updated
  • Loading branch information
mstoykov committed Aug 20, 2024
1 parent fd03ba6 commit c5dc773
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ issues:
# files (due to common repeats and long functions in test code)
- path: _(test|gen)\.go
linters:
- canonicalheader
- cyclop
- dupl
- gocognit
Expand Down Expand Up @@ -68,6 +69,7 @@ linters:
- asciicheck
- bidichk
- bodyclose
- canonicalheader
- contextcheck
- cyclop
- dogsled
Expand All @@ -79,6 +81,7 @@ linters:
- errorlint
- exhaustive
- exportloopref
- fatcontext
- forbidigo
- forcetypeassert
- funlen
Expand Down
2 changes: 1 addition & 1 deletion cloudapi/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const (
// MaxRetries specifies max retry attempts
MaxRetries = 3

k6IdempotencyKeyHeader = "k6-Idempotency-Key"
k6IdempotencyKeyHeader = "K6-Idempotency-Key"
)

// Client handles communication with the k6 Cloud API.
Expand Down
2 changes: 1 addition & 1 deletion cloudapi/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (c *Config) logtailConn(ctx context.Context, referenceID string, since time
headers := make(http.Header)
headers.Add("Sec-WebSocket-Protocol", "token="+c.Token.String)
headers.Add("Authorization", "token "+c.Token.String)
headers.Add("X-K6TestRun-Id", referenceID)
headers.Add("X-K6testrun-Id", referenceID)

var conn *websocket.Conn
err = retry(sleeperFunc(time.Sleep), 3, 5*time.Second, 2*time.Minute, func() (err error) {
Expand Down
2 changes: 1 addition & 1 deletion lib/executor/vu_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func (vh *vuHandle) runLoopsIfPossible(runIter func(context.Context, lib.ActiveV
// we need to cancel the context, to return the vu
// and because *we* did, lets reinitialize it
cancel()
vh.ctx, vh.cancel = context.WithCancel(vh.parentCtx)
vh.ctx, vh.cancel = context.WithCancel(vh.parentCtx) //nolint:fatcontext // isn't actually on the same context
}
fallthrough // to set the state
case toHardStop:
Expand Down

0 comments on commit c5dc773

Please sign in to comment.