should use make(chan struct{}) instead
1553 done chan struct{}
1554 end chan struct{}
1555 }{
1556 start: make(chan struct{}, 0),1557 done: make(chan struct{}, 0),
1558 end: make(chan struct{}, 0),
1559 }
should use make(chan struct{}) instead
1555 }{
1556 start: make(chan struct{}, 0),
1557 done: make(chan struct{}, 0),
1558 end: make(chan struct{}, 0),1559 }
1560 defer func() {
1561 // make sure that tindex.applyQuotas ends properly.
should use make(chan struct{}) instead
1554 end chan struct{}
1555 }{
1556 start: make(chan struct{}, 0),
1557 done: make(chan struct{}, 0),1558 end: make(chan struct{}, 0),
1559 }
1560 defer func() {
Description
The make
function has default values for the length and capacity arguments.
- For channels and maps, the length defaults to zero.
- For slices the capacity defaults to the length.
Bad practice
ch = make(chan int, 0)
sl = make([]int, 1, 1)
Recommended
ch = make(chan int, 0)
sl = make([]int, 1, 1)
However, using named constants with channels is not considered an antipattern, for accommodating debugging, math, or platform-specific code.
const c = 0
ch = make(chan int, ch) // No issues raised