Documentation ¶
Overview ¶
Package fetch for download, provide high performance download
use Goroutine to parallel download, use WaitGroup to do concurrency control.
Index ¶
Examples ¶
Constants ¶
View Source
const ( FileFlag = os.O_WRONLY | os.O_CREATE FileMode = 0644 )
FileFlag save file flag
FileMode save file mode
Variables ¶
View Source
var (
WaitPool = sync.WaitGroup{}
)
WaitPool implement request pool to enhance performance
Functions ¶
func GetFileLength ¶
GetFileLength will return http response content-length example:
GetFileLength("http://xxx")
Example ¶
requestURL := "http://httpbin.org/bytes/%d" var length1K int64 = 1024 lengthResult, _ := GetFileLength(fmt.Sprintf(requestURL, length1K)) fmt.Println(lengthResult)
Output: 1024
func GoroutineDownload ¶
GoroutineDownload will download form requestURL. example:
requestURL := "http://xxx" GoroutineDownload(requestURL, 20, 10*1024*1024, 30)
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.