The analyzer has detected a potential error caused by passing the same argument multiple times when a method or function is calling.
The example N1:
func Do(mX, mY, mZ int) {
....
}
func (vec Vector) Foo() {
Do(vec.x, vec.y, vec.y)
}
In the Do function signature and its call, the vec.y argument is passed twice. Most likely, the mZ parameter was intended to receive vec.z.
The fixed code:
func (vec Vector) Foo() {
Do(vec.x, vec.y, vec.z)
}
Passing identical arguments to certain standard library functions (math.Min, math.Max, and strings.Replace) may also be an error.
The example N2:
var count, capacity int
....
size := math.Max(float64(count), float64(count))
Due to a typo, math.Max compares the count variable with itself. Therefore, the function always returns the value of count.
The fixed code:
size := math.Max(float64(count), float64(capacity))
Was this page helpful?
Your message has been sent. We will email you at
If you do not see the email in your inbox, please check if it is filtered to one of the following folders: