Go

Go

Made by DeepSource

Simplify make call by omitting redundant arguments SCC-S1019

Anti-pattern
Major
Autofix

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