A download manager package for Go
Downloading the internet, one goroutine at a time!
To use the package in your own program:
$ go get github.com/cavaliergopher/grab/v3
To install the grab command line downloader:
$ go install github.com/cavaliergopher/grab/v3/cmd/grab@latest
Grab is a Go package for downloading files from the internet with the following rad features:
Requires Go v1.23+
The following example downloads a PDF copy of the free eBook, "An Introduction to Programming in Go" into the current working directory.
resp, err := grab.Get(".", "http://www.golang-book.com/public/pdf/gobook.pdf")
if err != nil {
log.Fatal(err)
}
fmt.Println("Download saved to", resp.Filename)
The following, more complete example allows for more granular control and periodically prints the download progress until it is complete.
The second time you run the example, it will auto-resume the previous download and exit sooner.
…
The primary use case for Grab is to concurrently downloading thousands of large files from remote file repositories where the remote files are immutable. Examples include operating system package repositories or ISO libraries.
Grab aims to provide robust, sane defaults. These are usually determined using the HTTP specifications, or by mimicking the behavior of common web clients like cURL, wget and common web browsers.
Grab aims to be stateless. The only state that exists is the remote files you
wish to download and the local copy which may be completed, partially completed
or not yet created. The advantage to this is that the local file system is not
cluttered unnecessarily with addition state files (like a .crdownload file).
The disadvantage of this approach is that grab must make assumptions about the
local and remote state; specifically, that they have not been modified by
another program.
If the local or remote file are modified outside of grab, and you download the file again with resuming enabled, the local file will likely become corrupted. In this case, you might consider making remote files immutable, or disabling resume.
Grab aims to enable best-in-class functionality for more complex features through extensible interfaces, rather than reimplementation. For example, you can provide your own Hash algorithm to compute file checksums, or your own rate limiter implementation (with all the associated trade-offs) to rate limit downloads.
What unit does the rate limiter interface operate on?
Checksum progress
Proposal: support new request to writer
Download failed: unexpected EOF
Support multiple connections / multipart download
open file failure, got err bad content length
Update project on golang.org
Unresolved: client.HTTPClient.Transport
http: ContentLength=111 with Body length 0
rate limiter is not accurate