Вебинар: Go-Go-Gadg...Error? Смотрим, как ошибаются Go разработчики! - 26.08
V8011. An identical expression to the left and to the right of a compound assignment.
V8011 Identical expression 'wg.width' to the left and to the right of compound assignment. widget_group.go 55
func (wg *WidgetGroup) adjustSize(w Widget) {
x, y := w.GetPosition()
width, height := w.GetSize()
if x+width > wg.x+wg.width {
wg.width += (x + width) - (wg.x + wg.width) // <= (1)
}
if wg.x > x {
wg.width += wg.x - x
wg.x = x
}
if y+height > wg.y+wg.height {
wg.height += (y + height) - (wg.y + wg.height) // <= (2)
}
if wg.y > y {
wg.height += wg.y - y
wg.y = y
}
}
Similar errors can be found in some other places:
V8011 Identical expression 'previousNum' to the left and to the right of compound assignment. paginator.go 177
func (p *Paginator) Pages() []*Page {
....
previousNum := getMiddleIdx(p.numPages) - 1
if previousNum > p.current-1 {
previousNum -= previousNum - (p.current - 1)
}
....
}
V8011 Identical expression 'm[1]' to the left and to the right of compound assignment. linkify.go 108
func (s *linkifyParser) Parse(....) ast.Node {
....
if m != nil {
lastChar := line[m[1]-1]
if lastChar == '.' {
m[1]--
} else if lastChar == ')' {
....
} else if lastChar == ';' {
i := m[1] - 2
for ; i >= m[0]; i-- {
if util.IsAlphaNumeric(line[i]) {
continue
}
break
}
if i != m[1]-2 {
if line[i] == '&' {
m[1] -= m[1] – i // <=
}
}
}
}
....
}