Skip to content

Instantly share code, notes, and snippets.

@blixt
Created August 3, 2011 21:14
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 blixt/1123791 to your computer and use it in GitHub Desktop.
Save blixt/1123791 to your computer and use it in GitHub Desktop.
Gogogogo!
package main
import "fmt"
type Person struct {
name string
age int
}
func (person *Person) Present() {
fmt.Println(person.name, "is", person.age, "years old")
}
type Dog struct {
nick string
}
func (dog *Dog) Present() {
fmt.Println(dog.nick, "is a dog")
}
type presenter interface {
Present()
}
func PrettyPresent(obj presenter) {
fmt.Print(".-´¨`-._.-´¨`-._.-´¨`-.\n* ")
obj.Present()
fmt.Println("`-._.-´¨`-._.-´¨`-._.-´")
}
func post_do() {
if err := recover(); err != nil {
fmt.Println("omg!", err)
} else {
fmt.Println("ok!")
}
}
func do_something() int {
defer post_do()
a := []int{1, 2, 3}
return a[1337]
}
func main() {
andreas := &Person{"Andreas", 24}
candy := &Dog{"Candy"}
candy.Present()
PrettyPresent(candy)
andreas.Present()
PrettyPresent(andreas)
do_something()
fmt.Println("lol, j/k")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment