Help us shape the future of Go! Take the 2026 Go Developer Survey

get

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2026 License: MIT Imports: 22 Imported by: 0

README

get

A multi-connection file downloader using parallel HTTP range requests.

get -p 4 https://example.com/file.tar.gz
 ████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░  11% 1.79 MiB/s
  • Fast: downloads a file using multiple connections
  • Resumable: keeps downloaded chunks and continues where it left off
  • Mirror-aware: can download from multiple URLs at once
  • Cross-platform: builds on Windows, Linux and macOS

Install

Build from source (requires Go 1.27.1+):

go install github.com/setanarut/get/cmd/get@latest

Usage

Download a file with 4 connections:

get -p 4 https://example.com/file.tar.gz

Save to a specific path:

get -o ./downloads/file.tar.gz https://example.com/file.tar.gz

Download from multiple mirrors at the same time:

get -p 2 https://mirror-a.com/file.tar.gz https://mirror-b.com/file.tar.gz

URLs can also be passed through stdin, one per line.

Resume

If a download is interrupted (ctrl+c), run the same command again. The downloaded chunks are stored in a _<filename>.partial directory next to the output file and reused on the next run.

./get https://example.com/file.tar.gz ████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 17% 1.77 MiB/s ^C ./get https://example.com/file.tar.gz ███████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 21% 1.74 MiB/s ^C

Because chunks are stored by their byte offset, you can resume with a different -p value and the already downloaded data is still reused.

Notes

  • The server must support HTTP range requests (Accept-Ranges: bytes).
  • Using many connections to a single URL can put load on the server. In most cases 4 or fewer is enough.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Download

func Download(ctx context.Context, c *DownloadConfig, opts ...DownloadOption) error

Types

type CheckConfig

type CheckConfig struct {
	URLs    []string
	Timeout time.Duration
	Client  *http.Client
}

CheckConfig is a configuration to check download target.

type DownloadConfig

type DownloadConfig struct {
	Filename      string
	Dirname       string
	ContentLength int64
	Procs         int
	URLs          []string
	Client        *http.Client
	// contains filtered or unexported fields
}

type DownloadOption

type DownloadOption func(c *DownloadConfig)

func WithReferer

func WithReferer(referer string) DownloadOption

func WithUserAgent

func WithUserAgent(ua, version string) DownloadOption

type Get

type Get struct {
	Output string
	Procs  int
	URLs   []string
	// contains filtered or unexported fields
}

Get struct

func New

func New() *Get

New for Get package

func (*Get) Run

func (g *Get) Run(ctx context.Context, version string, args []string) error

Run parses the command line arguments with cobra and executes the download. With -h / --help, cobra prints the usage and returns nil without running the download, so no "URL is required at least one" error is returned.

type Range

type Range struct {
	// contains filtered or unexported fields
}

Range struct for range access

func (Range) BytesRange

func (r Range) BytesRange() string

type Target

type Target struct {
	Filename      string
	ContentLength int64
	URLs          []string
}

Target represensts download target.

func Check

func Check(ctx context.Context, c *CheckConfig) (*Target, error)

Check checks be able to download from targets

Directories

Path Synopsis
cmd
get command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL