In golang, often you want to declare a pointer-type associated method, because you don't want to copy a huge struct around:
func (a *HugeStructType) AMethod() {
....
}
In C++, when I wanted to make such a method, but guarantee that it didn't mutate the underlying struct, I declared it const
:
class HugeStructType {
public:
void AMethod() const
...
}
Is there an equivalent in golang? If not, is there an idiomatic way to create a pointer-type-associated method which is known not to change the underlying structure?