gdf

package module
v0.0.0-...-da41e97 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2023 License: MulanPSL-2.0 Imports: 14 Imported by: 0

README

gdf

介绍

使用Golang编写的文件下载模块,基于原作者分享内容进行微改,如侵权请联系我关闭该项目

Golang多线程下载器(附代码、可执行文件)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadFile

func DownloadFile(urls, file string, threadCount int)

DownloadFile 下载文件并自定义保存文件路径

func DownloadFileDefault

func DownloadFileDefault(urls, folders string, threadCount int)

DownloadFileDefault 下载文件并使用URL最后一组作为文件名,例如http://qq/QQ9.6.2.exe则使用QQ9.6.2.exe

func GetBytesFile

func GetBytesFile(filename string, bufferSize int) []byte

func SafeMkdir

func SafeMkdir(folder string)

func TestDownload

func TestDownload(urlStr string, perThreadSize int) (int, map[int]string, []string, string, error)

func Version

func Version()

Types

type DownloadFileParams

type DownloadFileParams struct {
	UrlStr       string
	RangeStr     string
	RangeIndex   int
	TempFilename string
	Successed    bool
}

type DownloadTask

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

type DownloadThreadController

type DownloadThreadController struct {
	TaskQueue              chan DownloadTask       // 用于接收下载任务
	TaskCount              chan int                // 用于记载当前任务数量
	Exit                   chan int                // 用于记载当前任务数量
	ThreadCount            int                     // 最大协程数
	WaitGroup              sync.WaitGroup          // 等待协程完成
	RangeStrs              map[int]string          // 所有需要下载的文件名
	FileUrl                string                  // 下载链接
	DownloadResultInfoChan chan DownloadFileParams // 下载任务响应通道
	DownloadFolder         string                  // 下载文件保存文件夹
	DownloadFileName       string                  // 下载文件保存文件名
	Filenames              []string                // 子文件名,有序
}

func (*DownloadThreadController) Init

func (controller *DownloadThreadController) Init()

func (*DownloadThreadController) Run

func (controller *DownloadThreadController) Run()

Jump to

Keyboard shortcuts

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