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

get

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: MIT Imports: 24 Imported by: 0

README

get

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

  • 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

Usage: get [options] URL
  Options:
  -h,  --help                   print usage and exit
  -p,  --procs <num>            the number of connections for a single URL (default 1)
  -o,  --output <filename>      output file to <filename>
  -t,  --timeout <seconds>      timeout of checking request in seconds (default 10s)
  -u,  --user-agent <agent>     identify as <agent>
  -r,  --referer <referer>      identify as <referer>
  --check-update                check if there is update available
  --trace                       display detail error messages
Examples

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

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 {
	Trace  bool
	Output string
	Procs  int
	URLs   []string
	// contains filtered or unexported fields
}

Get structs

func New

func New() *Get

New for Get package

func (*Get) Ready

func (Get *Get) Ready(version string, args []string) error

Ready method define the variables required to Download.

func (*Get) Run

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

Run execute methods in Get package

type Options

type Options struct {
	Help          bool   `short:"h" long:"help"`
	NumConnection int    `short:"p" long:"procs" default:"1"`
	Output        string `short:"o" long:"output"`
	Timeout       int    `short:"t" long:"timeout" default:"10"`
	UserAgent     string `short:"u" long:"user-agent"`
	Referer       string `short:"r" long:"referer"`
	Update        bool   `long:"check-update"`
	Trace         bool   `long:"trace"`
}

Options struct for parse command line arguments

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