Parameter before the function name in Go?

Viewed 13044

I have seen some Go functions defined like this:

type poly struct {
    coeffs [256]uint16
}

func (p *poly) reset() {
    for i := range p.coeffs {
        p.coeffs[i] = 0
    }
}

Which you can later call as:

var p poly
p.reset()

I haven't seen this in other programming languages that I know. What's the purpose of p *poly in the reset function? It seems to be like a function parameter but written before the function name. Any clarification for it?

1 Answers
Related