| 1 | package main |
| 2 | |
| 3 | import "fmt" |
| 4 | |
| 5 | type funclistItem func() |
| 6 | |
| 7 | type funclist struct { |
| 8 | list []funclistItem |
| 9 | } |
| 10 | |
| 11 | func main() { |
| 12 | funcs := funclist{} |
| 13 | |
| 14 | funcs.list = append(funcs.list, func() { fmt.Println("first") }) |
| 15 | |
| 16 | for _, f := range funcs.list { |
| 17 | f() |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | // Output: |
| 22 | // first |