func (d *Download) Get() (err error) {
	defer close(d.Progress)
	offset, err := d.Target.Size()
	if err != nil {
		return
	}
	req, err := http.NewRequest(d.Method, d.Url, nil)
	if err != nil {
		return
	}
	trans := d.HttpClient.Transport
	if trans == nil {
		trans = http.DefaultTransport
	}
	d.HttpClient.Transport = &roundTripper{
		RoundTripFn: func(r *http.Request) (*http.Response, error) {
			if offset > 0 {
				r.Header.Add("Range", fmt.Sprintf("%d-", offset))
			}
			r.Header.Add("Accept-Encoding", "gzip")
			return trans.RoundTrip(r)
		},
	}
	resp, err := d.HttpClient.Do(req)
	if err != nil {
		return
	}
	defer resp.Body.Close()
	switch resp.StatusCode {
	case 200, 206:
	default:
		err = fmt.Errorf("Non 2XX response when downloading update: %s", resp.Status)
		return
	}
	clength := resp.ContentLength
	rd := resp.Body
	if clength > 0 {
		rd = &meteredReader{rd: rd, totalSize: clength, progress: d.Progress}
	}
	if resp.Header.Get("Content-Encoding") == "gzip" {
		rd, err = gzip.NewReader(rd)
		if err != nil {
			return
		}
	}
	_, err = io.Copy(d.Target, rd)
	if err != nil {
		return
	}
	return
}
Get() downloads the content of a url to a target destination.

Only HTTP/1.1 servers that implement the Range header support resuming a
partially completed download.

On success, the server must return 200 and the content, or 206 when resuming a partial download.
If the HTTP server returns a 3XX redirect, it will be followed according to d.HttpClient's redirect policy.
package download
import (
	"bytes"
	"compress/gzip"
	"fmt"
	"io"
	"net/http"
	"os"
	"runtime"
)
type roundTripper struct {
	RoundTripFn func(*http.Request) (*http.Response, error)
}
func (rt *roundTripper) RoundTrip(r *http.Request) (*http.Response, error) {
	return rt.RoundTripFn(r)
}
type Download struct {
	HttpClient *http.Client
	Target Target
	Progress chan (int)
	Method string
	Url string
}
func New(url string, target Target) *Download {
	return &Download{
		HttpClient: new(http.Client),
		Progress:   make(chan int),
		Method:     "GET",
		Url:        url,
		Target:     target,
	}
}