utils

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDirectoryIfNotExists

func CreateDirectoryIfNotExists(path string) error

func EscapeJsonMultilineStrings added in v1.0.0

func EscapeJsonMultilineStrings(data []byte) []byte

func FormatBytes

func FormatBytes(v float32) (string, string)

func FormatDuration

func FormatDuration(d timeseries.Duration, limitFirstN int) string

func FormatDurationShort

func FormatDurationShort(d timeseries.Duration, limitFirstN int) string

func FormatFloat

func FormatFloat(v float32) string

func FormatImage added in v0.21.0

func FormatImage(orig string) string

func FormatLatency

func FormatLatency(v float32) string

func FormatMoney

func FormatMoney(v float32) string

func FormatPercentage

func FormatPercentage(v float32) string

func GlobMatch

func GlobMatch(s string, patterns []string) bool

func GlobValidate

func GlobValidate(patterns []string) bool

func HumanBits

func HumanBits(v float32) string

func LastPart

func LastPart(s string, sep string) string

func NanoId

func NanoId(size int) string

func ParseHeatmapDuration added in v1.0.0

func ParseHeatmapDuration(s string) time.Duration

func ParseTime

func ParseTime(now timeseries.Time, val string, def timeseries.Time) timeseries.Time

func ReadJson

func ReadJson(r *http.Request, dest any) error

func WriteJson

func WriteJson(w http.ResponseWriter, v any)

Types

type BasicAuth

type BasicAuth struct {
	User     string `json:"user"`
	Password string `json:"password"`
}

func (*BasicAuth) AddTo

func (ba *BasicAuth) AddTo(address string) (string, error)
type Header struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

func (Header) Valid

func (h Header) Valid() bool

type StringSet

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

func NewStringSet

func NewStringSet(items ...string) *StringSet

func (*StringSet) Add

func (ss *StringSet) Add(items ...string)

func (*StringSet) Delete

func (ss *StringSet) Delete(s string)

func (*StringSet) Has

func (ss *StringSet) Has(s string) bool

func (*StringSet) Items

func (ss *StringSet) Items() []string

func (*StringSet) Len

func (ss *StringSet) Len() int

func (*StringSet) MarshalJSON

func (ss *StringSet) MarshalJSON() ([]byte, error)

Jump to

Keyboard shortcuts

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