Skip to content

Instantly share code, notes, and snippets.

@acroca
Last active September 24, 2015 16:10
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 acroca/a1d02ab2a745a6610fff to your computer and use it in GitHub Desktop.
Save acroca/a1d02ab2a745a6610fff to your computer and use it in GitHub Desktop.
package main
import "fmt"
type Something interface {
DoA()
DoB()
}
type Person struct {
}
func (p *Person) DoA() {
fmt.Println("Person A")
}
func (p *Person) DoB() {
fmt.Println("Person B")
}
type SuperPerson struct {
Something
}
func (p *SuperPerson) DoA() {
fmt.Println("SuperPerson A")
}
func main() {
p := &Person{}
sp := &SuperPerson{p}
test(sp)
}
func test(obj Something) {
obj.DoA()
obj.DoB()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment