Documentation ¶
Overview ¶
Package streamy provides functions for streams.
Index ¶
- Variables
- func HaveSeeker(i interface{}) bool
- func HaveStdin() (bool, error)
- func Index(r io.Reader, search []byte, readSize int) (index int64, read int64, err error)
- func ReaderOnly(r io.Reader) io.Reader
- func TeeReaderN(r io.Reader, w io.Writer, n int64) io.Reader
- type BinaryUnit
- type Progress
- func (progress *Progress) BytesWritten() int64
- func (progress *Progress) DisableStats()
- func (progress *Progress) EnableControls() error
- func (progress *Progress) EnableStats(mode ProgressStatsMode) error
- func (progress *Progress) SetTotalSize(size int64, unit BinaryUnit)
- func (progress *Progress) Stats() ProgressStats
- func (progress *Progress) Stop()
- func (progress *Progress) TotalBytes() int64
- func (progress *Progress) Write(p []byte) (n int, err error)
- type ProgressStats
- type ProgressStatsMode
Constants ¶
This section is empty.
Variables ¶
var ErrProgressStopped = errors.New("stopped")
ErrProgressStopped means that a progress stopped (i.e. by calling Stop method).
var ( // ProgressStatsModeSimple represents the simple progress stats mode. ProgressStatsModeSimple = ProgressStatsMode{/* contains filtered or unexported fields */} )
Functions ¶
func HaveSeeker ¶
func HaveSeeker(i interface{}) bool
HaveSeeker checks whether the given interface implements io.Seeker or not.
func Index ¶
Index returns the index of the first instance of the given byte slice, number of bytes read and error if any.
func ReaderOnly ¶
ReaderOnly takes any interface that implements io.Reader and returns just an io.Reader. It's useful for converting "advanced" readers (i.e. io.Seeker) to streams.
Types ¶
type BinaryUnit ¶
type BinaryUnit int64
BinaryUnit represents the binary unit type.
const ( // Byte represent the byte unit type. Byte BinaryUnit = 1 // KB represent the KB unit type. KB BinaryUnit = 1000 // MB represent the MB unit type. MB BinaryUnit = 1000 * KB // GB represent the GB unit type. GB BinaryUnit = 1000 * MB // TB represent the TB unit type. TB BinaryUnit = 1000 * GB // PB represent the PB unit type. PB BinaryUnit = 1000 * TB // KiB represent the KiB unit type. KiB BinaryUnit = 1024 // MiB represent the MiB unit type. MiB BinaryUnit = 1024 * KiB // GiB represent the GiB unit type. GiB BinaryUnit = 1024 * MiB // TiB represent the TiB unit type. TiB BinaryUnit = 1024 * GiB // PiB represent the PiB unit type. PiB BinaryUnit = 1024 * TiB )
type Progress ¶
type Progress struct {
// contains filtered or unexported fields
}
Progress implements the io.Writer interface for tracking bytes.
func (*Progress) BytesWritten ¶
BytesWritten returns the number of bytes written.
func (*Progress) DisableStats ¶
func (progress *Progress) DisableStats()
DisableStats disables the progress stats.
func (*Progress) EnableControls ¶ added in v0.2.0
EnableControls enables the progress controls such as pause and stop.
func (*Progress) EnableStats ¶
func (progress *Progress) EnableStats(mode ProgressStatsMode) error
EnableStats enables the progress stats.
func (*Progress) SetTotalSize ¶
func (progress *Progress) SetTotalSize(size int64, unit BinaryUnit)
SetTotalSize sets the total size by the given size and binary unit.
func (*Progress) Stats ¶
func (progress *Progress) Stats() ProgressStats
Stats returns the progress stats.
func (*Progress) Stop ¶ added in v0.2.0
func (progress *Progress) Stop()
Stop stops the the progress writer.
func (*Progress) TotalBytes ¶
TotalBytes returns the total number of bytes.
type ProgressStats ¶
type ProgressStats struct { TotalBytes int64 BytesWritten int64 BytesPerSecond int64 Took time.Duration Remaining time.Duration Percentage int }
ProgressStats represents the progress stats.
type ProgressStatsMode ¶
type ProgressStatsMode struct {
// contains filtered or unexported fields
}
ProgressStatsMode represents a progress stats mode.