Feature: Add goctl env (#1557)
This commit is contained in:
23
tools/goctl/pkg/downloader/downloader.go
Normal file
23
tools/goctl/pkg/downloader/downloader.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package downloader
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
func Download(url string, filename string) error {
|
||||
resp, err := http.Get(url)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
f, err := os.Create(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
_, err = io.Copy(f, resp.Body)
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user