structの関数プロパティとメソッドの挙動
package main import "fmt" type OpFunc func(int, int) int type Operation struct { // associateされていないのでOperationのプロパティ・メソッドへのアクセスは出来ない。 Do1 OpFunc // 以下コメントを外すと "type Operation has both field and method named Do2" //Do2 OpFunc } func (op Operation) Do2(a, b int) int { return op.Do1(a, b) } func main() { op := &Operation{ Do1: func(a, b int) int { return a + b }, } fmt.Println(op.Do1(1, 2), op.Do2(3, 4)) }