Move Go() promise-like func from utils to pkg/promise
This is the first of two steps to break the archive package's dependence on utils so that archive may be moved into pkg. Also, the `Go()` function is small, concise, and not specific to the docker internals, so it is a good candidate for pkg. Signed-off-by: Rafe Colton <rafael.colton@gmail.com> Upstream-commit: b845a62149d5f4990462ac6c9167c5cfaa0e66cb Component: engine
This commit is contained in:
@ -30,16 +30,6 @@ type KeyValuePair struct {
|
||||
Value string
|
||||
}
|
||||
|
||||
// Go is a basic promise implementation: it wraps calls a function in a goroutine,
|
||||
// and returns a channel which will later return the function's return value.
|
||||
func Go(f func() error) chan error {
|
||||
ch := make(chan error, 1)
|
||||
go func() {
|
||||
ch <- f()
|
||||
}()
|
||||
return ch
|
||||
}
|
||||
|
||||
// Request a given URL and return an io.Reader
|
||||
func Download(url string) (resp *http.Response, err error) {
|
||||
if resp, err = http.Get(url); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user