internal/build: simplify DownloadFile for Go 1.11 compatibility

This commit is contained in:
Felix Lange 2019-11-15 13:52:36 +01:00
parent a471b8242b
commit cdee268677

View file

@ -18,7 +18,6 @@ package build
import ( import (
"bufio" "bufio"
"context"
"crypto/sha256" "crypto/sha256"
"encoding/hex" "encoding/hex"
"fmt" "fmt"
@ -29,7 +28,6 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
"time"
) )
// ChecksumDB keeps file checksums. // ChecksumDB keeps file checksums.
@ -88,13 +86,7 @@ func (db *ChecksumDB) DownloadFile(url, dstPath string) error {
return err return err
} }
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute) resp, err := http.Get(url)
defer cancel()
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
if err != nil {
return err
}
resp, err := http.DefaultClient.Do(req)
if err != nil || resp.StatusCode != http.StatusOK { if err != nil || resp.StatusCode != http.StatusOK {
return fmt.Errorf("download error: code %d, err %v", resp.StatusCode, err) return fmt.Errorf("download error: code %d, err %v", resp.StatusCode, err)
} }