3 ms·
Here's one possibility. With an interface: https://go.dev/play/p/WTo2k_7PeRT https://go.dev/play/p/WTo2k_7PeRT type Barker interface { Name() string
by benhoyt 3y ago
Here's one possibility. With an interface: https://go.dev/play/p/WTo2k_7PeRT https://go.dev/play/p/WTo2k_7PeRT
type Barker interface {
Name() string
Bark()
}
And with a function-struct: https://go.dev/play/p/A_p40q1ARyR https://go.dev/play/p/A_p40q1ARyR
type Barker struct {
Name func() string
Bark func()
}