Slide 15
Slide 15 text
A custom filter example
15
func implementsStringer(ctx *dsl.VarFilterContext) bool {
stringer := ctx.GetInterface(`fmt.Stringer`)
// pointer to the captured, type, T -> *T
ptr := types.NewPointer(ctx.Type)
return types.Implements(ctx.Type, stringer) ||
types.Implements(ptr, stringer)
}
How to execute?