Giter Club home page Giter Club logo

gorc's Introduction

多线程并发下载器-gorc

gorc是类wget多线程下载器,支持直接从资源url并发获取资源

初入社会所作,停止维护,仅供学习使用,不当之处多多包含

使用说明:

1.手动选择模式和自动分配模式,参数:manual,默认为false/自动
2.指定并发线程数,参数:thread,默认为5
3.指定下载的url,参数:url
4.指定分块下载的块大小,参数:blockSize,例如,默认1代表16m,2代表32m,4代表64m,以此类推
5.指定分块下载失败后尝试次数,参数:attempt,默认为3
6.指定文件存放位置,参数:root,默认为项目的lib目录
7.程序使用秩序调用gorc.Download(url string)函数即可

功能点:

1.支持多线程并发下载
2.支持断点续传
3.支持进度条显示
4.支持手动设置临时文件大小
5.支持自动清理缓存文件

效果示例:

Windows7下
自动模式

自动续传模式

手动模式

手动续传模式

gorc's People

Contributors

v-i-c-t-o-r avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

gorc's Issues

占用cpu非常高,

url替换为 “http://lax-ca-us-ping.vultr.com/vultr.com.1000MB.bin”

C:\Temp>example -manual=true -thread=10
2019/01/20 18:15:50 manual pattern
2019/01/20 18:15:50 start download
2019/01/20 18:15:50 file C:\Temp\lib\vultr.com.1000MBa87ff679a2f3e71d9181a67b7542122c start 104857600
2019/01/20 18:15:50 file C:\Temp\lib\vultr.com.1000MBeccbc87e4b5ce2fe28308fd9f2a7baf3 start 104857600
2019/01/20 18:15:50 file C:\Temp\lib\vultr.com.1000MBc4ca4238a0b923820dcc509a6f75849b start 104857600
2019/01/20 18:15:50 file C:\Temp\lib\vultr.com.1000MBc9f0f895fb98ab9159f51fd0297e236d start 104857600
2019/01/20 18:15:50 file C:\Temp\lib\vultr.com.1000MB8f14e45fceea167a5a36dedd4bea2543 start 104857600
2019/01/20 18:15:50 file C:\Temp\lib\vultr.com.1000MB1679091c5a880faf6fb5e6087eb1b2dc start 104857600
2019/01/20 18:15:50 file C:\Temp\lib\vultr.com.1000MBc81e728d9d4c2f636f067f89cc14862c start 104857600
2019/01/20 18:15:50 file C:\Temp\lib\vultr.com.1000MBd3d9446802a44259755d38e6d163e820 start 104857600
2019/01/20 18:15:50 file C:\Temp\lib\vultr.com.1000MB45c48cce2e2d7fbdea1afc51c7c6ad26 start 104857600
2019/01/20 18:15:50 file C:\Temp\lib\vultr.com.1000MBe4da3b7fbbce2345d7772b0674a318d5 start 104857600
working 100%[====================================================================================================]  109s
2019/01/20 18:17:48 download completed

100Mbps带宽跑满,cpu飚升到25%+
我使用 Internet Download Manager 32个并发下载,同样带宽跑满100Mbps,cpu只有1-5之间浮动,

请问:http.go文件中设置文件头的目的是什么

func sendGet(url string, address string, start int64, end int64) (len int64, err error) {
	var req *http.Request
	req, err = http.NewRequest("GET", url, nil)
	req.Header.Set("Range", "bytes="+strconv.FormatInt(start, 10)+"-"+strconv.FormatInt(end, 10))
	req.Header.Set("Connection", "close")
	tr := &http.Transport{
		TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
	}
	client := &http.Client{Transport: tr}
	var resp *http.Response
	resp, err = client.Do(req)
	defer resp.Body.Close()
	file, err := createFile(address)
	len, err = io.Copy(file, resp.Body)
	return len, err
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.