-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
GoGo LanguageGo Language
Description
package main
import "fmt"
type Downloader interface {
Download(url string)
}
type BaiduDownloader struct {
}
func (BaiduDownloader) Download(url string) {
fmt.Println("Download Baidu:", url)
}
type YoukuDownloader struct {
}
func (YoukuDownloader) Download(url string) {
fmt.Println("Download Youku:", url)
}
func Process(url string, d Downloader) {
d.Download(url)
}
func main() {
url := "youku-url"
Process(url, YoukuDownloader{})
url = "baidu-url"
Process(url, BaiduDownloader{})
}Metadata
Metadata
Assignees
Labels
GoGo LanguageGo Language