Skip to content

Instantly share code, notes, and snippets.

@lysu
Created March 7, 2016 16:39
Show Gist options
  • Save lysu/93c352dfe1eabe5bfc50 to your computer and use it in GitHub Desktop.
Save lysu/93c352dfe1eabe5bfc50 to your computer and use it in GitHub Desktop.
/* start prcess/process.go */
package process
type Processer struct{
fetch Fetch // use processor's field
}
func (p *Processor) Process(x string) { // as processer metho
fetch.Fetch(x)
}
/* end prcess/process.go */
/* start fetch/fetch.go */
package fetch
type Fetch interface {
Fetch(x string)
}
type httpFetch struct {
}
// ............
func NewHttpFetch() Fetch {
return &httpFetch
}
/* end fetch/fetch.go */
/* start main.go */
package main
func main() {
hf := fetch.NewHttpFetch()
p := process.Processer{
fetch: hf,
}
p.Process("11211")
}
/* end main.go */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment