github.com/traefik/yaegi@v0.15.1/_test/interface11.go (about) 1 package main 2 3 import "fmt" 4 5 type Error interface { 6 error 7 Code() string 8 } 9 10 type MyError Error 11 12 type T struct { 13 Name string 14 } 15 16 func (t *T) Error() string { return "err: " + t.Name } 17 func (t *T) Code() string { return "code: " + t.Name } 18 19 func newT(s string) MyError { return &T{s} } 20 21 func main() { 22 t := newT("foo") 23 fmt.Println(t.Code()) 24 } 25 26 // Output: 27 // code: foo