/splitter

Simple Go package for file chunk async download that made just for fun.

Primary LanguageGoMIT LicenseMIT

GoDoc Build Status codecov.io Go Report Card

Splitter

Simple Go package for file chunk async download that made just for fun. Choose a file, slice it up, download it. Please do not set 20 chunks for a 10kb file.

Installation

Fetch package

go get github.com/AlexyAV/splitter
import (
  splitter "github.com/AlexyAV/splitter"
)

Usage

func main() {
	// With absolute destination path
	pr := splitter.NewPathResolver(
		"https://via.placeholder.com/3000",
		"/tmp/",
		&http.Client{},
	)
	pi, err := pr.PathInfo()
	if err != nil {
		log.Fatal(err)
	}

	// Create Splitter instance with new PathInfo and 10 chunks
	s := splitter.NewSplitter(context.Background(), pi, 10, &http.Client{})

	// Start file download
	err = s.Download()
	if err != nil {
		log.Fatal(err)
	}
}