55 new issues, consisting of 36 bug risks and 19 antipatterns, have been added.
Some of the new issues that have been added are:
-
Violation of cgo pointer passing rules
Attempts to pass a Gochan
,map
,func
, or slice to C, either directly, or via a pointer, array, orstruct
is not recommended. This is because the values of these types (apart from zero-value) always contain Go pointers, which is not allowed by the cgo pointer passing rules. -
Incorrect usage of
sync/atomic
package
This issue is raised in case of redundant assignment after calling anatomic.Add*
function. -
sync.WaitGroup
expected as a by-value parameter in a function or method
Function parameters that are passed by value, are in fact a copy of the original argument. Passing a copy of async.WaitGroup
is usually not what you’d want to do. -
Possibly undesired value being used in goroutine
Range variables in a loop are reused at each iteration; therefore a goroutine created in a loop will point to the range variable with from the upper scope. This way, the goroutine could use the variable with an undesired value. This rule warns when a range value (or index) is used inside a closure -
Method expression can be replaced with method call
It is simpler to use receiver functions of a type by calling them directly, rather than using selector syntax to select a function and then pass a receiver.