-
-
Save azhuox/263b4adc983e26763fb9069c8d5b36cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package interfaceexample | |
import ( | |
"fmt" | |
) | |
// FlyBehaviour defines an interface for fly behaviour | |
type FlyBehaviour interface { | |
Fly() | |
Type() string | |
} | |
// FlyWithWings defines the fly behavior with wings. | |
type FlyWithWings struct { | |
} | |
func (f *FlyWithWings) Fly() { | |
fmt.Print("Fly with wings!\n") | |
} | |
func (f *FlyWithWings) Type() string { | |
return "fly-with-wings" | |
} | |
// FlyWithWings defines the fly behavior with super power. | |
type FlyWithSuperPower struct { | |
} | |
func (f *FlyWithSuperPower) Fly() { | |
fmt.Print("Fly with super power!\n") | |
} | |
func (f *FlyWithSuperPower) Type() string { | |
return "fly-with-super-power" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment