Skip to content

Commit 5655f4f

Browse files
mpywclaude
andcommitted
docs: fix spawnerlabel examples in README
- Fix missing label example to show func parameter being spawned - Add unnecessary label example (no spawn, no func parameters) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 6cb70c6 commit 5655f4f

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

README.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -317,30 +317,34 @@ Available flags:
317317

318318
### `-spawnerlabel`
319319

320-
When enabled, checks that functions calling spawn methods have the `//goroutinectx:spawner` directive:
320+
When enabled, checks that functions calling spawn methods with func arguments have the `//goroutinectx:spawner` directive:
321321

322322
```go
323-
// Bad: calls errgroup.Group.Go but missing directive
324-
func runTasks() { // Warning: should have //goroutinectx:spawner
323+
// Bad: calls errgroup.Group.Go with func argument but missing directive
324+
func runTask(task func() error) { // Warning: should have //goroutinectx:spawner
325325
g := new(errgroup.Group)
326-
g.Go(func() error {
327-
return doWork()
328-
})
326+
g.Go(task)
329327
_ = g.Wait()
330328
}
331329

332330
// Good: properly labeled
333331
//goroutinectx:spawner
334-
func runTasks() {
332+
func runTask(task func() error) {
335333
g := new(errgroup.Group)
336-
g.Go(func() error {
337-
return doWork()
338-
})
334+
g.Go(task)
339335
_ = g.Wait()
340336
}
341337
```
342338

343-
Also warns about unnecessary labels on functions that don't spawn and have no func parameters.
339+
Also warns about unnecessary labels on functions that don't spawn and have no func parameters:
340+
341+
```go
342+
// Bad: unnecessary directive (no spawn calls, no func parameters)
343+
//goroutinectx:spawner
344+
func simpleHelper() { // Warning: unnecessary //goroutinectx:spawner
345+
fmt.Println("hello")
346+
}
347+
```
344348

345349
## Design Principles
346350

0 commit comments

Comments
 (0)