Go Short Variable Declaration Invalid Cases

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

Internal

With Package-Level Variables

TODO

With Method Receivers' Fields

...

type A struct {
    i int
}

func (a A) m(i int) {
    a.i := i + 1 // invalid
}

...

Compiler error:

./main.go:12: non-name a.i on left side of :=