util

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KILO SizeUnit = 1000
	MEGA          = 1000 * KILO
	GIGA          = 1000 * MEGA
)
View Source
const (
	DrySuffix = ":dry"
	GzSuffix  = ".gz"
)

Variables

This section is empty.

Functions

func IsDrySuffix

func IsDrySuffix(file string) bool

func MergeCodes

func MergeCodes(codes []string) string

func ParseEnvDuration

func ParseEnvDuration(name string, defaultValue time.Duration) time.Duration

func ReadFile

func ReadFile(f *os.File) ([]byte, error)

ReadFile reads the named file and returns the contents. A successful call returns err == nil, not err == EOF. Because ReadFile reads the whole file, it does not treat an EOF from Read as an error to be reported.

func TrimDrySuffix

func TrimDrySuffix(file string) string

Types

type Features

type Features map[string]bool

Features defines a feature map.

func NewFeatures

func NewFeatures(features ...string) Features

func (*Features) Has

func (f *Features) Has(feature string) bool

Has tells the feature map contains a features.

func (*Features) HasAny

func (f *Features) HasAny(features ...string) bool

HasAny tells the feature map contains any of the features.

func (*Features) IsNop

func (f *Features) IsNop() bool

func (*Features) Setup

func (f *Features) Setup(featuresArr []string)

Setup sets up a feature map by features string, which separates feature names by comma.

type Float64

type Float64 float64

func BytesToBPS

func BytesToBPS(bytes uint64, d time.Duration) Float64

func BytesToGiga

func BytesToGiga(bytes uint64) Float64

func BytesToMBS

func BytesToMBS(bytes uint64, d time.Duration) Float64

func BytesToMEGA

func BytesToMEGA(bytes uint64) Float64

func NumberToRate

func NumberToRate(num uint64, d time.Duration) Float64

func (Float64) MarshalJSON

func (f Float64) MarshalJSON() ([]byte, error)

type GoroutineIncr

type GoroutineIncr struct {
	Up   int
	Dur  time.Duration
	Down int
}

func ParseGoIncr

func ParseGoIncr(s string) GoroutineIncr

ParseGoIncr parse a GoIncr expressions like: 1. (empty) => GoroutineIncr{} 2. 0 => GoroutineIncr{} 3. 1 => GoroutineIncr{Up: 1} 4. 1:10s => GoroutineIncr{Up: 1, Dur:10s} 5. 1:10s:1 => GoroutineIncr{Up: 1, Dur:10s, Down:1}

func (GoroutineIncr) IsEmpty

func (i GoroutineIncr) IsEmpty() bool

func (GoroutineIncr) Modifier

func (i GoroutineIncr) Modifier() string

type JSONLogFile

type JSONLogFile struct {
	F *os.File
	*sync.Mutex
	Dry     bool
	Closed  bool
	HasRows bool
	Name    string
}

func NewJsonLogFile

func NewJsonLogFile(file string) *JSONLogFile

func (*JSONLogFile) Close

func (f *JSONLogFile) Close() error

func (JSONLogFile) IsDry

func (f JSONLogFile) IsDry() bool

func (JSONLogFile) ReadAll

func (f JSONLogFile) ReadAll() []byte

func (*JSONLogFile) WriteJSON

func (f *JSONLogFile) WriteJSON(data []byte) error

type SizeUnit

type SizeUnit int

type WidthHeight

type WidthHeight struct {
	W, H int
}

func ParseWidthHeight

func ParseWidthHeight(val string, defaultWidth, defaultHeight int) WidthHeight

func (WidthHeight) HeightPx

func (h WidthHeight) HeightPx() string

func (WidthHeight) WidthPx

func (h WidthHeight) WidthPx() string

Jump to

Keyboard shortcuts

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