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

get

package module
v1.1.4 Latest Latest
Warning

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

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

README

get

A multi-connection file downloader using parallel HTTP range requests. Downloads are resumable and multiple mirror URLs can be used at once.

> get https://example.com/file.zip
63.97 MiB / 231.82 MiB  █████████░░░░░░░░░░░░░░░░░░░░░░  27.59% 1.80 MiB p/s ETA 1m33s
Usage:
  get [flags] URL...
Flags:
  -h, --help                Help for get
  -o, --output string       Output file to <filename>
  -p, --procs int           The number of connections for a single URL (default 1)
  -r, --referer string      Identify as <referer>
  -t, --timeout int         Set timeout of checking request in seconds (default 10)
  -u, --user-agent string   Identify as <agent>
  -v, --version             Version for get

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.zip

Save to a specific path:

get -o ./downloads/file.zip https://example.com/file.zip

Download from multiple mirrors at the same time:

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

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.zip
73.17 MiB / 231.82 MiB  ████████████░░░░░░░░░░░░░░░░░░░░░░░  31.56% 1.78 MiB p/s ETA 1m28s
^C
> get https://example.com/file.zip
94.28 MiB / 231.82 MiB  ███████████████░░░░░░░░░░░░░░░░░░░░  40.67% 1.76 MiB p/s ETA 1m17s
^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