Skip to content

[lint-monster] Replace map[string]bool with map[string]struct{} for Set Operations #37048

Closed as not planned

Description

@github-actions

[lint-monster] Replace map[string]bool with map[string]struct{} for Set Operations

Status

Issue Count: 243 instances
Last Updated: 2026-06-05

Overview

When using maps as sets (checking membership, not storing values), replace map[string]bool with map[string]struct{} to avoid memory overhead.

Pattern

Current (wasteful):

seen := make(map[string]bool)
seen[key] = true
if seen[key] {
    // ...
}

Recommended (efficient):

seen := make(map[string]struct{})
seen[key] = struct{}{}
if _, ok := seen[key]; ok {
    // ...
}

Benefits:

  • Zero-size struct{} is more explicit about intent (set, not boolean mapping)
  • Saves memory: no bool value allocated per entry
  • Idiomatic Go for set implementations

Distribution by Package

Package Count
pkg/workflow/ ~150
pkg/parser/ ~50
pkg/cli/ ~20
Other ~23

Refactoring Strategy

  1. Identify set-only usage: Maps where values are only set to true and checked for existence
  2. Replace declaration: Change map[string]bool to map[string]struct{}
  3. Update assignments: Replace m[key] = true with m[key] = struct{}{}
  4. Update checks: Use if _, ok := m[key] pattern instead of if m[key]

Validation

make golint-custom

All map-bool-as-set findings should resolve.

Refactoring Checklist

  • Phase 1: Update pkg/workflow/ instances (~150)
  • Phase 2: Update pkg/parser/ instances (~50)
  • Phase 3: Update pkg/cli/ and other packages (~73)
  • Verify with make golint-custom
  • Run make build && make fmt

Generated by 🧌 LintMonster · 177 AIC · ◷

  • expires on Jun 12, 2026, 3:50 AM UTC

Activity

  1. added
    cookie
    on Jun 5, 2026
  2. github-actions commented on Jun 6, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · haiku45 324.5K · 97.4 AIC · ⌖ 4.33 AIC · ◷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

automationcookielint

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions