| 1 | package main |
| 2 | |
| 3 | type Sample struct { |
| 4 | Name string |
| 5 | Foo []string |
| 6 | } |
| 7 | |
| 8 | func (s *Sample) foo(j int) { |
| 9 | for i, v := range s.Foo { |
| 10 | println(i, v) |
| 11 | } |
| 12 | } |
| 13 | |
| 14 | var samples = []Sample{ |
| 15 | Sample{"hello", []string{"world"}}, |
| 16 | } |
| 17 | |
| 18 | func main() { |
| 19 | samples[0].foo(3) |
| 20 | } |
| 21 | |
| 22 | // Output: |
| 23 | // 0 world |