utils

package
v1.6.6 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 24 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 FormatLinkStats added in v1.4.0

func FormatLinkStats(requests, latency, bytesSent, bytesReceived float32, issue string) []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 IsIpDocker added in v1.3.0

func IsIpDocker(ip netaddr.IP) bool

func IsIpExternal added in v1.4.1

func IsIpExternal(ip netaddr.IP) bool

func IsIpPrivate added in v1.3.0

func IsIpPrivate(ip netaddr.IP) bool

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 RandomString added in v1.5.0

func RandomString(size int) string

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 StaticFSWrapper added in v1.5.0

type StaticFSWrapper struct {
	http.FileSystem
	// contains filtered or unexported fields
}

func NewStaticFSWrapper added in v1.5.0

func NewStaticFSWrapper(fs fs.FS) *StaticFSWrapper

func (*StaticFSWrapper) Open added in v1.5.0

func (f *StaticFSWrapper) Open(name string) (http.File, error)

type StaticFileInfoWrapper added in v1.5.0

type StaticFileInfoWrapper struct {
	os.FileInfo
	// contains filtered or unexported fields
}

func (*StaticFileInfoWrapper) ModTime added in v1.5.0

func (f *StaticFileInfoWrapper) ModTime() time.Time

type StaticFileWrapper added in v1.5.0

type StaticFileWrapper struct {
	http.File
	// contains filtered or unexported fields
}

func (*StaticFileWrapper) Stat added in v1.5.0

func (f *StaticFileWrapper) Stat() (os.FileInfo, error)

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