Skip to content

Fix lint-go CI failures#31762

Merged
pelikhan merged 3 commits into
mainfrom
copilot/fix-lint-go-job-failure
May 12, 2026
Merged

Fix lint-go CI failures#31762
pelikhan merged 3 commits into
mainfrom
copilot/fix-lint-go-job-failure

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 12, 2026

Five golangci-lint violations introduced by recent changes were breaking the lint-go CI job.

Bug Fix

What was the bug?

The following linter errors were reported:

Linter File Issue
gofmt compiler_experiments_sparse_interaction_warning_test.go Redundant []string type in map[string][]string composite literals
intrange runtime_detection.go Classic 3-clause for loop indexing into a slice
modernize engine_helpers.go HasSuffix + TrimSuffix pair replaceable with CutSuffix
staticcheck SA6002 workflows.go sync.Pool.Put called with []byte (non-pointer), causing slice header copies
staticcheck QF1001 firewall_args_test.go Negated conjunction not simplified via De Morgan's law

How did you fix it?

  • gofmt: ran gofmt -s — removes redundant element types in composite literals
  • intrange: for i := 0; i < len(words)-1; i++for i := range len(words)-1
  • modernize: HasSuffix + TrimSuffixstrings.CutSuffix
  • SA6002: pool stores *[]byte instead of []byte; defer writes back the (possibly reallocated) slice before returning the pointer
  • QF1001: !(A && B && C)A >= B || B >= C || C >= D
// Before (SA6002)
var workflowTitleScannerBufferPool = sync.Pool{
    New: func() any { return make([]byte, workflowTitleScannerBufferSize) },
}
scannerBuffer := workflowTitleScannerBufferPool.Get().([]byte)
defer workflowTitleScannerBufferPool.Put(scannerBuffer)

// After
var workflowTitleScannerBufferPool = sync.Pool{
    New: func() any { b := make([]byte, workflowTitleScannerBufferSize); return &b },
}
scannerBufferPtr := workflowTitleScannerBufferPool.Get().(*[]byte)
defer func() {
    *scannerBufferPtr = scannerBuffer
    workflowTitleScannerBufferPool.Put(scannerBufferPtr)
}()

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix failing GitHub Actions job lint-go Fix lint-go CI failures May 12, 2026
Copilot AI requested a review from pelikhan May 12, 2026 18:39
@pelikhan pelikhan marked this pull request as ready for review May 12, 2026 18:45
Copilot AI review requested due to automatic review settings May 12, 2026 18:45
@pelikhan pelikhan merged commit 6d841f5 into main May 12, 2026
16 of 18 checks passed
@pelikhan pelikhan deleted the copilot/fix-lint-go-job-failure branch May 12, 2026 18:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes lint-go CI failures by addressing five golangci-lint violations introduced in recent changes.

Changes:

  • Modernized loops and string handling (intrange, modernize) and applied gofmt -s composite literal simplifications.
  • Refactored sync.Pool usage to store *[]byte to satisfy staticcheck SA6002.
  • Simplified a negated test condition using De Morgan’s law (staticcheck QF1001).
Show a summary per file
File Description
pkg/workflow/runtime_detection.go Replaces an index-based loop with an integer range loop to satisfy intrange.
pkg/workflow/firewall_args_test.go Simplifies a negated conjunction into ordered >= checks for QF1001.
pkg/workflow/engine_helpers.go Uses strings.CutSuffix instead of HasSuffix + TrimSuffix (modernize).
pkg/workflow/compiler_experiments_sparse_interaction_warning_test.go Applies gofmt -s composite literal element type elision.
pkg/cli/workflows.go Adjusts sync.Pool buffer storage to avoid slice-header copies (SA6002).

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 5/5 changed files
  • Comments generated: 1

Comment on lines +376 to +377
if after, found := strings.CutSuffix(cmdStr, " *"); found {
return after, true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants