Skip to content

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

@github-actions

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

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions