diff --git a/goutil.go b/goutil.go index 99a5a6d..f8aac3b 100644 --- a/goutil.go +++ b/goutil.go @@ -6,6 +6,7 @@ import ( "flag" "fmt" "io/ioutil" + "net/http" "os" "os/exec" "os/user" @@ -310,3 +311,16 @@ func Notify(head string, body string) error { } return nil } + +func Download(url string) ([]byte, error) { + resp, err := http.Get(url) + if err != nil { + return nil, errors.New("Download: " + err.Error()) + } + defer resp.Body.Close() + data, err := ioutil.ReadAll(resp.Body) + if err != nil { + return nil, errors.New("Download: " + err.Error()) + } + return data, err +}