util

package
v0.0.0-...-7234002 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyAndClose

func CopyAndClose(dst io.WriteCloser, src io.Reader) (written int64, err error)

func ParseVersionJSON

func ParseVersionJSON(raw []byte) (int, bool)

Parses any JSON map of (string) keys to whatever, and returns the value of the "version" key as an integer. Otherwise, returns (-1, false).

Types

type AutoCloseReader

type AutoCloseReader struct {
	RC io.ReadCloser
}

Wrapper around io.ReadCloser making an io.Reader that automatically closes.

func (*AutoCloseReader) Read

func (a *AutoCloseReader) Read(b []byte) (int, error)

type ByteCount

type ByteCount float64

func (ByteCount) String

func (t ByteCount) String() string

Return a byte count, cleaned up for pretty output.

type IntervalTimer

type IntervalTimer interface {
	Stop()
}

func NewTimer

func NewTimer(millis int, f func()) IntervalTimer

Start a timer that will call back to a function every N milliseconds.

type ProgressFunc

type ProgressFunc func(progress, total int)

type ProgressReader

type ProgressReader struct {
	Reader io.Reader // underlying reader
	Size   int       // total size of data
	// contains filtered or unexported fields
}

An io.Reader that outputs its progress every N milliseconds.

func NewProgressReader

func NewProgressReader(r io.Reader, size int, millis int, f ProgressFunc) *ProgressReader

func (*ProgressReader) Read

func (r *ProgressReader) Read(b []byte) (int, error)

Read from the underlying source, increment our progress and stop the timer if we're done.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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