[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
- Identify set-only usage: Maps where values are only set to
true and checked for existence
- Replace declaration: Change
map[string]bool to map[string]struct{}
- Update assignments: Replace
m[key] = true with m[key] = struct{}{}
- Update checks: Use
if _, ok := m[key] pattern instead of if m[key]
Validation
All map-bool-as-set findings should resolve.
Refactoring Checklist
Generated by 🧌 LintMonster · 177 AIC · ◷
[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]boolwithmap[string]struct{}to avoid memory overhead.Pattern
Current (wasteful):
Recommended (efficient):
Benefits:
struct{}is more explicit about intent (set, not boolean mapping)Distribution by Package
Refactoring Strategy
trueand checked for existencemap[string]booltomap[string]struct{}m[key] = truewithm[key] = struct{}{}if _, ok := m[key]pattern instead ofif m[key]Validation
All map-bool-as-set findings should resolve.
Refactoring Checklist
make golint-custommake build && make fmt