Skip to content

Instantly share code, notes, and snippets.

@azhuox

azhuox/block1.go Secret

Created December 7, 2020 04:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azhuox/263b4adc983e26763fb9069c8d5b36cd to your computer and use it in GitHub Desktop.
Save azhuox/263b4adc983e26763fb9069c8d5b36cd to your computer and use it in GitHub Desktop.
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