Created
March 22, 2015 13:34
-
-
Save mrkplt/b114d2525a03cfb95acd to your computer and use it in GitHub Desktop.
Revisions
-
mrkplt created this gist
Mar 22, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ # https://www.youtube.com/watch?v=gRpUfjTwSOo&utm_source=golangweekly&utm_medium=email package main import "fmt" type user struct { name string email string } type admin struct { user level string } func(u *user) notify() { fmt.Printf("Sending email to %s<%s>\n", u.name, u.email, ) } type notifier interface { notify() } func main() { foo := user{ name: "Randolf Gorgeous", email: "[email protected]", } admin := admin{ user: user{ name: "mark platt", email: "[email protected]", }, level: "super", } sendNotification(&admin) sendNotification(&foo) } func sendNotification(n notifier) { n.notify() }