cccp

package module
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2018 License: MIT Imports: 18 Imported by: 0

README

cccp

Build Status GoDoc MIT License

Description

A library that provides a concurrent copy function with progress bars.

See godoc for complete documentation.

Screenshot

Screenshot 01

Screenshot 02

Usage

package main

import (
	"context"
	"log"
	"path"

	"github.com/unblee/cccp"
)

func main() {
	urls := []string{
		"https://dl.google.com/go/go1.11.linux-amd64.tar.gz",
		"https://dl.google.com/go/go1.11.windows-amd64.msi",
		"https://dl.google.com/go/go1.11.darwin-amd64.pkg",
	}

	for _, url := range urls {
		err := cccp.SetFromURLToFile(url, path.Base(url), "")
		if err != nil {
			log.Fatalln(err)
		}
	}

	cccp.SetOptions(cccp.WithConcurrentNumCPU())
	// cccp.SetOptions(cccp.WithConcurrent(1), cccp.WithEnableSequentialProgressbars())
	err := cccp.Run(context.Background())
	if err != nil {
		log.Fatalln(err)
	}
}

Installation

$ go get github.com/unblee/cccp

TODO

  • Add tests

Contribution

  1. Fork(https://github.com/unblee/cccp/fork)
  2. Create a branch (git checkout -b my-fix)
  3. Commit your changes (git commit -am "fix something")
  4. Push to the branch (git push origin my-fix)
  5. Create a new Pull Request
  6. Have a coffee break and wait

Author

unblee

License

license

Documentation

Overview

Package cccp provides a concurrent copy function with progress bars.

Index

Constants

View Source
const Version = "0.5.1"

Version is package version.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context) error

Run start concurrent copy.

func SetFromFileToFile

func SetFromFileToFile(src, dst, name string) error

SetFromFileToFile set the source file path and destination file path of the copy target. name is the name displayed in the progress bar. If name is empty, "src -> dst" is set.

func SetFromHTTPRequestToFile added in v0.5.0

func SetFromHTTPRequestToFile(src *http.Request, dst, name string) error

SetFromHTTPRequestToFile set the source http.Request and destination file path of the copy target. name is the name displayed in the progress bar. If name is empty, src URL base is set.

func SetFromSourceToDestination added in v0.5.0

func SetFromSourceToDestination(src source.Source, dst destination.Destination, name string) error

SetFromSourceToDestination set the source and destination of the copy target. name is the name displayed in the progress bar.

func SetFromSourceToFile added in v0.5.0

func SetFromSourceToFile(src source.Source, dst, name string) error

SetFromSourceToFile set the source and destination file path of the copy target. name is the name displayed in the progress bar. If name is empty, src URL base is set.

func SetFromURLToFile

func SetFromURLToFile(src, dst, name string) error

SetFromURLToFile set the source URL and destination file path of the copy target. name is the name displayed in the progress bar. If name is empty, src URL base is set.

func SetOptions

func SetOptions(opts ...Option)

SetOptions set options to manager.

Types

type Option

type Option func(*manager)

Option is a setting to change the behavior of manager.

func WithConcurrent

func WithConcurrent(n int) Option

WithConcurrent set the number of concurrent execution.

func WithConcurrentNumCPU

func WithConcurrentNumCPU() Option

WithConcurrentNumCPU set the number of concurrent execution to the number of CPU cores.

func WithDisableProgressbars

func WithDisableProgressbars() Option

WithDisableProgressbars set not to display the progress bars.

func WithEnableSequentialProgressbars

func WithEnableSequentialProgressbars() Option

WithEnableSequentialProgressbars progress bars are displayed sequentially.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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