| 1 | package main |
| 2 | |
| 3 | import "fmt" |
| 4 | |
| 5 | // Filter is a filter |
| 6 | type Filter interface { |
| 7 | Foo() |
| 8 | } |
| 9 | |
| 10 | // GIFT is a gift |
| 11 | type GIFT struct { |
| 12 | Filters []Filter |
| 13 | } |
| 14 | |
| 15 | // New is a new filter list |
| 16 | func New(filters ...Filter) *GIFT { |
| 17 | return &GIFT{ |
| 18 | Filters: filters, |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | // List lists filters |
| 23 | func (g *GIFT) List() { |
| 24 | fmt.Printf("Hello from List!\n") |
| 25 | } |
| 26 | |
| 27 | // MyFilter is one of the filters |
| 28 | type MyFilter struct{} |
| 29 | |
| 30 | // Foo is a foo |
| 31 | func (f *MyFilter) Foo() {} |
| 32 | |
| 33 | func main() { |
| 34 | g := New(&MyFilter{}) |
| 35 | g.List() |
| 36 | } |
| 37 | |
| 38 | // Output: |
| 39 | // Hello from List! |