Created
July 17, 2016 04:30
-
-
Save gerep/1654a740d190c5162e278d93b613c5b4 to your computer and use it in GitHub Desktop.
This file contains 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 characters
package main | |
import "log" | |
type Admin struct { | |
*User | |
Level string | |
} | |
func (a *Admin) Notify() error { | |
log.Printf("Admin: Sending Admin Email to %s<%s>\n", | |
a.Name, | |
a.Email) | |
return nil | |
} | |
type User struct { | |
Name string | |
Email string | |
} | |
func (u *User) Notify() error { | |
log.Printf("User: Sending User Email to %s<%s>\n", | |
u.Name, | |
u.Email) | |
return nil | |
} | |
type Notifier interface { | |
Notify() error | |
} | |
func SendNotification(notify Notifier) error { | |
return notify.Notify() | |
} | |
func main() { | |
admin := &Admin { | |
User: &User{"Bill", "[email protected]"}, | |
Level: "super", | |
} | |
SendNotification(admin) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment