Created
March 7, 2016 16:39
-
-
Save lysu/93c352dfe1eabe5bfc50 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
/* 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