Skip to content

Instantly share code, notes, and snippets.

@hfogelberg
Created April 25, 2017 13:16
Show Gist options
  • Save hfogelberg/47fcf3d488ceec24a0c49a424a00ab8e to your computer and use it in GitHub Desktop.
Save hfogelberg/47fcf3d488ceec24a0c49a424a00ab8e to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
)
type person struct {
fname string
lname string
}
type jedi struct {
person
hasForce bool
}
func (p person) speak() {
fmt.Println("I want money, says " + p.fname + " " + p.lname)
}
func(j jedi) speak() {
fmt.Println(j.fname + " says May the force be with you")
}
type human interface {
speak()
}
func main() {
p1 := person{"Han", "Solo"}
fmt.Println(p1)
j1 := jedi{
person {
"Luke",
"Skywalker",
} ,
true,
}
p1.speak()
j1.speak()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment