Skip to content

Fix CI lint failure by preallocating parseSampleGroups result slice - #20

Merged
Breee merged 2 commits into
mainfrom
copilot/fix-lint-failing-job
May 26, 2026
Merged

Fix CI lint failure by preallocating parseSampleGroups result slice#20
Breee merged 2 commits into
mainfrom
copilot/fix-lint-failing-job

Conversation

Copilot AI commented May 26, 2026

Copy link
Copy Markdown
Contributor

The CI lint job failed on main due to a prealloc violation in hack/gen-ai-docs/main.go. The failure was isolated to parseSampleGroups, where the output slice was appended without capacity preallocation.

  • What changed

    • Updated parseSampleGroups to preallocate groups with len(kindOrder) before the append loop.
    • Removed the earlier zero-capacity declaration of groups.
  • Why this addresses the issue

    • Aligns the function with golangci-lint’s prealloc requirement while preserving existing behavior and output order.
  • Code change (excerpt)

// before
var groups []SampleGroup
for _, kind := range kindOrder {
    g := kindGroups[kind]
    g.Description = descriptions[kind]
    groups = append(groups, *g)
}

// after
groups := make([]SampleGroup, 0, len(kindOrder))
for _, kind := range kindOrder {
    g := kindGroups[kind]
    g.Description = descriptions[kind]
    groups = append(groups, *g)
}

Copilot AI changed the title [WIP] Fix failing GitHub Actions job lint Fix CI lint failure by preallocating parseSampleGroups result slice May 26, 2026
Copilot AI requested a review from Breee May 26, 2026 05:29
Copilot finished work on behalf of Breee May 26, 2026 05:29
@Breee
Breee marked this pull request as ready for review May 26, 2026 06:22
@Breee
Breee merged commit 031232a into main May 26, 2026
6 checks passed
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.

2 participants