downloader

package module
v2.0.4-0...-9eb7e21 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2021 License: MIT Imports: 10 Imported by: 0

README

介绍

这是一个可以进行http下载文件的库,支持终端进度条,进度条可以自适应终端宽度,同时支持windows和linux。

使用

package main

import (
	"fmt"
	"os"
	"path/filepath"

	"gitee.com/qiuzhiqian/downloader"
)

func main() {
	dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
	if err != nil {
		return
	}
	filePath, err := downloader.Download("https://xxxxx.com", dir)
	if err != nil {
		return
	}
	fmt.Println("filePath:", filePath)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Version

func Version() string

Version is used to get the library version

Types

type Downloader

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

func NewDownloader

func NewDownloader() *Downloader

func (*Downloader) Download

func (dl *Downloader) Download(url, dest string) (string, error)

Download is used to download and file with terminal progress bar

func (*Downloader) SetProgressHandler

func (dl *Downloader) SetProgressHandler(ph func(name string, savedSize, sumSize int))

func (*Downloader) SetRenameHandler

func (dl *Downloader) SetRenameHandler(rh func(name string) (string, error))

Jump to

Keyboard shortcuts

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