downloadFile downloads a file from a url
(filepath string, url string)
| 57 | |
| 58 | // downloadFile downloads a file from a url |
| 59 | func downloadFile(filepath string, url string) (err error) { |
| 60 | out, err := os.Create(filepath) |
| 61 | if err != nil { |
| 62 | return err |
| 63 | } |
| 64 | defer out.Close() |
| 65 | |
| 66 | req, err := http.NewRequest("GET", url, nil) |
| 67 | if err != nil { |
| 68 | return err |
| 69 | } |
| 70 | resp, err := http.DefaultClient.Do(req) |
| 71 | if err != nil { |
| 72 | return err |
| 73 | } |
| 74 | defer resp.Body.Close() |
| 75 | |
| 76 | _, err = io.Copy(out, resp.Body) |
| 77 | if err != nil { |
| 78 | return err |
| 79 | } |
| 80 | |
| 81 | return nil |
| 82 | } |
| 83 | |
| 84 | // initInSteps() performs initialization in several steps |
| 85 | // The reason for spreading the initialization out in |
no test coverage detected
searching dependent graphs…