Refactor: Deduplicate gotask API definitions
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 0
- Forks
- 0
- Avg merge
- 8h 5m
- Merged PRs (30d)
- 12
Description
Problem
The gotask API list is defined in two separate locations with similar but slightly different metadata:
1. internal/apis.go - RegisterGotaskAPIs() (lines 71-89)
- Purpose: Used by spawnerlabel checker for spawner label validation
- Called from:
analyzer.go:123 - Data structure:
registry.EntrywithAlwaysSpawnsfield - APIs registered: DoAll, DoAllSettled, DoRace, DoAllFns, DoAllFnsSettled, DoRaceFns, Task.DoAsync, CancelableTask.DoAsync
2. internal/checkers/gotask.go - GotaskChecker.entries (lines 53-65)
- Purpose: Used by gotask checker for context propagation validation
- Called from:
analyzer.go:196-200 - Data structure:
gotaskEntrywithVariadicandIsDoAsyncfields - APIs registered: Same list as above
Issues
- DRY violation: The same API set is maintained in two places
- Maintenance burden: Adding/removing gotask APIs requires changes in both locations
- Inconsistency risk: The two lists could drift apart over time
Key Differences
While both define the same API set, they have different metadata requirements:
| Aspect | RegisterGotaskAPIs | GotaskChecker.entries |
|---|---|---|
| DoAsync CallbackArgIdx | Not specified | 0 (explicit) |
| Metadata fields | AlwaysSpawns | Variadic, IsDoAsync |
| Purpose | Spawner label detection | Context propagation checking |
Proposed Solution
Create a unified gotask API registry that both checkers can consume:
- Define a single source of truth for gotask APIs (e.g.,
internal/gotask/apis.go) - Provide adapter functions to convert to checker-specific formats:
ToRegistryEntries()→ for spawnerlabel checkerToGotaskEntries()→ for gotask checker
- Update both checkers to use the unified registry
This would maintain flexibility for checker-specific metadata while eliminating duplication.
Alternative
If the metadata requirements are too divergent, document why the duplication is necessary and add validation to ensure both lists stay in sync.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading internal/apis.go and internal/checkers/gotask.go, then inspect their call sites in analyzer.go at lines 123 and 196-200. Compare the two metadata formats and determine whether a shared registry with adapters is suitable. Done means both checkers consume one API definition, or the required duplication is documented and synchronization is validated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- devtools
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100