github.com/traefik/yaegi@v0.15.1/_test/issue-784.go (about)

     1  package main
     2  
     3  import "fmt"
     4  
     5  // Filter is a filter interface
     6  type Filter interface {
     7  	Bounds(srcBounds string) (dstBounds string)
     8  }
     9  
    10  // GIFT type
    11  type GIFT struct {
    12  	Filters []Filter
    13  }
    14  
    15  // New creates a new filter list and initializes it with the given slice of filters.
    16  func New(filters ...Filter) *GIFT {
    17  	return &GIFT{
    18  		Filters: filters,
    19  	}
    20  }
    21  
    22  // Bounds calculates the appropriate bounds for the result image after applying all the added filters.
    23  func (g *GIFT) Bounds(srcBounds string) (dstBounds string) {
    24  	dstBounds = srcBounds
    25  	for _, f := range g.Filters {
    26  		dstBounds = f.Bounds(dstBounds)
    27  	}
    28  	return dstBounds
    29  }
    30  
    31  func main() {
    32  	var filters []Filter
    33  	bounds := "foo"
    34  	g := New(filters...)
    35  	fmt.Println(g.Bounds(bounds))
    36  }
    37  
    38  // Output:
    39  // foo