Skip to content

Instantly share code, notes, and snippets.

@gerep
Created July 17, 2016 04:30
Show Gist options
  • Save gerep/1654a740d190c5162e278d93b613c5b4 to your computer and use it in GitHub Desktop.
Save gerep/1654a740d190c5162e278d93b613c5b4 to your computer and use it in GitHub Desktop.
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", "bill@email.com"},
Level: "super",
}
SendNotification(admin)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment