github.com/traefik/yaegi@v0.15.1/_test/struct21.go (about) 1 package main 2 3 type SecretProvider func(user, realm string) string 4 5 type BasicAuth struct { 6 Realm string 7 Secrets SecretProvider 8 } 9 10 func (a *BasicAuth) CheckAuth() string { return a.Secrets("me", a.Realm) } 11 12 func (a *BasicAuth) secretBasic(user, realm string) string { return a.Realm + "-" + user + "-" + realm } 13 14 func main() { 15 b := &BasicAuth{Realm: "test"} 16 b.Secrets = b.secretBasic 17 s := b.CheckAuth() 18 println(s) 19 } 20 21 // Output: 22 // test-me-test