common

package
v0.0.0-...-303e327 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

colorize defined

Functions

func BoldBar

func BoldBar(curr int) string

BoldBar returns bold progress bar like: [███▍ ]

curr is [0 - 100]

func CmdContext

func CmdContext() context.Context

CmdContext returns context with special reqest id tag

func Colorize

func Colorize(percent int) *color.Color

Colorize by int [-100, 100] percent Danger --> Optimal --> Danger

func ColorizeFloat

func ColorizeFloat(ratio float64) *color.Color

ColorizeFloat color by float64 [-1.0, 1.0] ratio

func ColorizeInt

func ColorizeInt(used, total int) *color.Color

ColorizeInt by int

func ColorizeInt32

func ColorizeInt32(used, total int32) *color.Color

ColorizeInt32 by int32

func ColorizeInt64

func ColorizeInt64(used, total int64) *color.Color

ColorizeInt64 by int64

func ColorizeUint32

func ColorizeUint32(used, total uint32) *color.Color

ColorizeUint32 by uint32

func ColorizeUint32Free

func ColorizeUint32Free(free, total uint32) *color.Color

ColorizeUint32Free free by uint32

func ColorizeUint64

func ColorizeUint64(used, total uint64) *color.Color

ColorizeUint64 by uint64

func ColorizeUint64Free

func ColorizeUint64Free(free, total uint64) *color.Color

ColorizeUint64Free free by uint64

func Confirm

func Confirm(s string) bool

Confirm ask for confirmation case insensitive 'y', 'yes', means yes case insensitive 'n', 'no', means no otherwise ask again

func LineBar

func LineBar(curr, width int) string

LineBar returns line progress bar like: [===============================================> ]

curr is [0 - 100] width is the length of bar

func Loader

func Loader(all int) chan<- int

Loader loader bar

func Marshal

func Marshal(v interface{}) ([]byte, error)

Marshal alias of json.Marshal

func NewDecoder

func NewDecoder(r io.Reader) *json.Decoder

NewDecoder alias of json.NewDecoder

func NewEncoder

func NewEncoder(w io.Writer) *json.Encoder

NewEncoder alias of json.NewEncoder

func RawString

func RawString(v interface{}) string

RawString returns json string

func Readable

func Readable(v interface{}) string

Readable print value of json

func Unmarshal

func Unmarshal(data []byte, val interface{}) error

Unmarshal alias of json.Unmarshal

Types

type AlternateColor

type AlternateColor struct {
	// contains filtered or unexported fields
}

AlternateColor alternate color formatter

func NewAlternateColor

func NewAlternateColor(n int) *AlternateColor

NewAlternateColor returns an alternate color formatter

func (*AlternateColor) Next

func (a *AlternateColor) Next() *color.Color

Next returns next color

type PReader

type PReader struct {
	// contains filtered or unexported fields
}

PReader progress bar for io.Reader example: reader := NewPReader(1024, r) defer reader.Close() reader.LineBar()

// balabala ...

func NewPReader

func NewPReader(total int, r io.Reader) *PReader

NewPReader returns a progress reader

func (*PReader) BoldBar

func (r *PReader) BoldBar()

BoldBar bold bar

func (*PReader) Close

func (r *PReader) Close()

Close the bar

func (*PReader) LineBar

func (r *PReader) LineBar(width int)

LineBar line bar

func (*PReader) Read

func (r *PReader) Read(p []byte) (n int, err error)

type PWriter

type PWriter struct {
	// contains filtered or unexported fields
}

PWriter progress bar for io.Writer

func NewPWriter

func NewPWriter(total int, w io.Writer) *PWriter

NewPWriter returns a progress writer

func (*PWriter) BoldBar

func (w *PWriter) BoldBar()

BoldBar bold bar

func (*PWriter) Close

func (w *PWriter) Close()

Close the bar

func (*PWriter) LineBar

func (w *PWriter) LineBar(width int)

LineBar line bar

func (*PWriter) Write

func (w *PWriter) Write(p []byte) (n int, err error)

Directories

Path Synopsis
Package cfmt provides fmt string for all struct in blobstore
Package cfmt provides fmt string for all struct in blobstore

Jump to

Keyboard shortcuts

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