pget

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 22, 2025 License: MIT Imports: 22 Imported by: 0

README

see origin source from https://github.com/Code-Hex/pget

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 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 Pget

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

Pget structs

func New

func New() *Pget

New for pget package

func (*Pget) Ready

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

Ready method define the variables required to Download.

func (*Pget) Run

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

Run execute methods in pget package

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
pget command

Jump to

Keyboard shortcuts

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