refactor download file

pull/42/head
Minh Doan 6 years ago
parent 4e22b46850
commit 5529f9819d
  1. 25
      aws-experiment-launch/experiment/commander/main.go

@ -4,6 +4,7 @@ import (
"bufio"
"flag"
"fmt"
"harmony-benchmark/aws-experiment-launch/experiment/utils"
"io"
"log"
"net"
@ -35,30 +36,8 @@ const (
DistributionFileName = "distribution_config.txt"
)
func downloadFile(filepath string, url string) {
// Create the file
out, err := os.Create(filepath)
if err != nil {
panic(err)
}
defer out.Close()
// Get the data
resp, err := http.Get(url)
if err != nil {
panic(err)
}
defer resp.Body.Close()
// Write the body to file
_, err = io.Copy(out, resp.Body)
if err != nil {
panic(err)
}
}
func readConfigFile() [][]string {
downloadFile(DistributionFileName, setting.configURL)
utils.DownloadFile(DistributionFileName, setting.configURL)
file, err := os.Open(DistributionFileName)
defer file.Close()

Loading…
Cancel
Save