funcs

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2023 License: MIT Imports: 45 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Nothing

func Nothing(v ...any) string

Types

type Cast

type Cast struct{}

Cast is a collection of cast github.com/spf13/cast functions.

func (Cast) StringToDate

func (Cast) StringToDate(s string) (time.Time, error)

func (Cast) StringToDateInDefaultLocation

func (Cast) StringToDateInDefaultLocation(s string, location *time.Location) (time.Time, error)

func (Cast) ToBool

func (Cast) ToBool(i interface{}) bool

func (Cast) ToBoolE

func (Cast) ToBoolE(i interface{}) (bool, error)

func (Cast) ToBoolSlice

func (Cast) ToBoolSlice(i interface{}) []bool

func (Cast) ToBoolSliceE

func (Cast) ToBoolSliceE(i interface{}) ([]bool, error)

func (Cast) ToDuration

func (Cast) ToDuration(i interface{}) time.Duration

func (Cast) ToDurationE

func (Cast) ToDurationE(i interface{}) (d time.Duration, err error)

func (Cast) ToDurationSlice

func (Cast) ToDurationSlice(i interface{}) []time.Duration

func (Cast) ToDurationSliceE

func (Cast) ToDurationSliceE(i interface{}) ([]time.Duration, error)

func (Cast) ToFloat32

func (Cast) ToFloat32(i interface{}) float32

func (Cast) ToFloat32E

func (Cast) ToFloat32E(i interface{}) (float32, error)

func (Cast) ToFloat64

func (Cast) ToFloat64(i interface{}) float64

func (Cast) ToFloat64E

func (Cast) ToFloat64E(i interface{}) (float64, error)

func (Cast) ToInt

func (Cast) ToInt(i interface{}) int

func (Cast) ToInt16

func (Cast) ToInt16(i interface{}) int16

func (Cast) ToInt16E

func (Cast) ToInt16E(i interface{}) (int16, error)

func (Cast) ToInt32

func (Cast) ToInt32(i interface{}) int32

func (Cast) ToInt32E

func (Cast) ToInt32E(i interface{}) (int32, error)

func (Cast) ToInt64

func (Cast) ToInt64(i interface{}) int64

func (Cast) ToInt64E

func (Cast) ToInt64E(i interface{}) (int64, error)

func (Cast) ToInt8

func (Cast) ToInt8(i interface{}) int8

func (Cast) ToInt8E

func (Cast) ToInt8E(i interface{}) (int8, error)

func (Cast) ToIntE

func (Cast) ToIntE(i interface{}) (int, error)

func (Cast) ToIntSlice

func (Cast) ToIntSlice(i interface{}) []int

func (Cast) ToIntSliceE

func (Cast) ToIntSliceE(i interface{}) ([]int, error)

func (Cast) ToSlice

func (Cast) ToSlice(i interface{}) []interface{}

func (Cast) ToSliceE

func (Cast) ToSliceE(i interface{}) ([]interface{}, error)

func (Cast) ToString

func (Cast) ToString(i interface{}) string

func (Cast) ToStringE

func (Cast) ToStringE(i interface{}) (string, error)

func (Cast) ToStringMap

func (Cast) ToStringMap(i interface{}) map[string]interface{}

func (Cast) ToStringMapBool

func (Cast) ToStringMapBool(i interface{}) map[string]bool

func (Cast) ToStringMapBoolE

func (Cast) ToStringMapBoolE(i interface{}) (map[string]bool, error)

func (Cast) ToStringMapE

func (Cast) ToStringMapE(i interface{}) (map[string]interface{}, error)

func (Cast) ToStringMapInt

func (Cast) ToStringMapInt(i interface{}) map[string]int

func (Cast) ToStringMapInt64

func (Cast) ToStringMapInt64(i interface{}) map[string]int64

func (Cast) ToStringMapInt64E

func (Cast) ToStringMapInt64E(i interface{}) (map[string]int64, error)

func (Cast) ToStringMapIntE

func (Cast) ToStringMapIntE(i interface{}) (map[string]int, error)

func (Cast) ToStringMapString

func (Cast) ToStringMapString(i interface{}) map[string]string

func (Cast) ToStringMapStringE

func (Cast) ToStringMapStringE(i interface{}) (map[string]string, error)

func (Cast) ToStringMapStringSlice

func (Cast) ToStringMapStringSlice(i interface{}) map[string][]string

func (Cast) ToStringMapStringSliceE

func (Cast) ToStringMapStringSliceE(i interface{}) (map[string][]string, error)

func (Cast) ToStringSlice

func (Cast) ToStringSlice(i interface{}) []string

func (Cast) ToStringSliceE

func (Cast) ToStringSliceE(i interface{}) ([]string, error)

func (Cast) ToTime

func (Cast) ToTime(i interface{}) time.Time

func (Cast) ToTimeE

func (Cast) ToTimeE(i interface{}) (tim time.Time, err error)

func (Cast) ToTimeInDefaultLocation

func (Cast) ToTimeInDefaultLocation(i interface{}, location *time.Location) time.Time

func (Cast) ToTimeInDefaultLocationE

func (Cast) ToTimeInDefaultLocationE(i interface{}, location *time.Location) (tim time.Time, err error)

func (Cast) ToUint

func (Cast) ToUint(i interface{}) uint

func (Cast) ToUint16

func (Cast) ToUint16(i interface{}) uint16

func (Cast) ToUint16E

func (Cast) ToUint16E(i interface{}) (uint16, error)

func (Cast) ToUint32

func (Cast) ToUint32(i interface{}) uint32

func (Cast) ToUint32E

func (Cast) ToUint32E(i interface{}) (uint32, error)

func (Cast) ToUint64

func (Cast) ToUint64(i interface{}) uint64

func (Cast) ToUint64E

func (Cast) ToUint64E(i interface{}) (uint64, error)

func (Cast) ToUint8

func (Cast) ToUint8(i interface{}) uint8

func (Cast) ToUint8E

func (Cast) ToUint8E(i interface{}) (uint8, error)

func (Cast) ToUintE

func (Cast) ToUintE(i interface{}) (uint, error)

type Codec

type Codec struct{}

func (Codec) ByteToString

func (Codec) ByteToString(b []byte) string

func (Codec) IndentByte

func (Codec) IndentByte(i int, data []byte) []byte

func (Codec) JsonDecode

func (Codec) JsonDecode(v []byte) (map[string]interface{}, error)

func (Codec) JsonEncode

func (Codec) JsonEncode(v any, pretty bool) ([]byte, error)

func (Codec) Markdown

func (Codec) Markdown(data []byte) []byte

func (Codec) StringToByte

func (Codec) StringToByte(s string) []byte

func (Codec) TomlDecode

func (Codec) TomlDecode(v []byte) (map[string]interface{}, error)

func (Codec) TomlEncode

func (Codec) TomlEncode(v any) ([]byte, error)

func (Codec) YamlDecode

func (Codec) YamlDecode(v []byte) (map[string]interface{}, error)

func (Codec) YamlEncode

func (Codec) YamlEncode(v any) ([]byte, error)

type Crypto

type Crypto struct{}

func (Crypto) Base64

func (Crypto) Base64(v any) (string, error)

func (Crypto) Base64B

func (Crypto) Base64B(v []byte) string

func (Crypto) Base64Decode

func (Crypto) Base64Decode(v any) ([]byte, error)

func (Crypto) FNV32a

func (Crypto) FNV32a(v any) (int, error)

FNV32a hashes v using fnv32a algorithm.

func (Crypto) HMAC

func (Crypto) HMAC(h interface{}, k interface{}, m interface{}) (string, error)

func (Crypto) MD5

func (Crypto) MD5(v any) (string, error)

func (Crypto) MD5B

func (Crypto) MD5B(v []byte) []byte

SHA1B hashes v and returns its SHA1 checksum in binary.

func (Crypto) SHA1

func (Crypto) SHA1(v any) (string, error)

SHA1 hashes v and returns its SHA1 checksum.

func (Crypto) SHA1B

func (Crypto) SHA1B(v []byte) []byte

SHA1B hashes v and returns its SHA1 checksum in binary.

func (Crypto) SHA256

func (Crypto) SHA256(v any) (string, error)

SHA256 hashes v and returns its SHA256 checksum.

func (Crypto) SHA256B

func (Crypto) SHA256B(v []byte) []byte

SHA256B hashes v and returns its SHA256 checksum in binary.

type Exec

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

func (Exec) Exec

func (e Exec) Exec(cli string) (map[string]interface{}, error)

type ExecTemplate

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

func (*ExecTemplate) ExecTemplate

func (e *ExecTemplate) ExecTemplate(name string, v any) (string, error)

type Faker

type Faker struct {
	faker.Faker
}

type File

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

func (*File) Read

func (f *File) Read(fileName string) ([]byte, error)

func (*File) Save deprecated

func (f *File) Save(fileName string, data []byte) (bool, error)

Deprecated: Use Write instead.

func (*File) Write

func (f *File) Write(fileName string, data []byte) (bool, error)

type HTML2 added in v0.3.0

type HTML2 struct{}

func (HTML2) EscapeString added in v0.3.0

func (HTML2) EscapeString(v string) string

func (HTML2) UnescapeString added in v0.3.0

func (HTML2) UnescapeString(v string) string

type Humanize

type Humanize struct{}

Humanize is a collection of humanize github.com/dustin/go-humanize functions.

func (Humanize) BigBytes

func (Humanize) BigBytes(s *big.Int) string

func (Humanize) BigComma

func (Humanize) BigComma(b *big.Int) string

func (Humanize) BigCommaf

func (Humanize) BigCommaf(v *big.Float) string

func (Humanize) BigIBytes

func (Humanize) BigIBytes(s *big.Int) string

func (Humanize) Bytes

func (Humanize) Bytes(v uint64) string

func (Humanize) Comma

func (Humanize) Comma(v int64) string

func (Humanize) Commaf

func (Humanize) Commaf(v float64) string

func (Humanize) CommafWithDigits

func (Humanize) CommafWithDigits(f float64, decimals int) string

func (Humanize) ComputeSI

func (Humanize) ComputeSI(input float64) (float64, string)

func (Humanize) CustomRelTime

func (Humanize) CustomRelTime(a time.Time, b time.Time, albl string, blbl string, magnitudes []humanize.RelTimeMagnitude) string

func (Humanize) FormatFloat

func (Humanize) FormatFloat(format string, n float64) string

func (Humanize) FormatInteger

func (Humanize) FormatInteger(format string, n int) string

func (Humanize) Ftoa

func (Humanize) Ftoa(num float64) string

func (Humanize) FtoaWithDigits

func (Humanize) FtoaWithDigits(num float64, digits int) string

func (Humanize) IBytes

func (Humanize) IBytes(v uint64) string

func (Humanize) Ordinal

func (Humanize) Ordinal(x int) string

func (Humanize) ParseBigBytes

func (Humanize) ParseBigBytes(s string) (*big.Int, error)

func (Humanize) ParseBytes

func (Humanize) ParseBytes(s string) (uint64, error)

func (Humanize) RelTime

func (Humanize) RelTime(a time.Time, b time.Time, albl string, blbl string) string

func (Humanize) SI

func (Humanize) SI(input float64, unit string) string

func (Humanize) Time

func (Humanize) Time(then time.Time) string

type Log

type Log struct{}

func (Log) Debug

func (Log) Debug(v any) any

func (Log) Error

func (Log) Error(v any) any

func (Log) Fatal

func (Log) Fatal(v any) any

func (Log) Info

func (Log) Info(v any) any

func (Log) Panic

func (Log) Panic(v any) any

func (Log) Warn

func (Log) Warn(v any) any

type Map

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

func (*Map) Get

func (m *Map) Get(key string, data map[string]interface{}) interface{}

func (*Map) Set

func (m *Map) Set(key string, value interface{}) map[string]interface{}

type Minify

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

func (*Minify) Minify

func (m *Minify) Minify(mType string, data []byte) ([]byte, error)

type Os

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

func (*Os) FileExists

func (o *Os) FileExists(i any) (bool, error)

FileExists checks whether a file exists under the given path.

func (*Os) ReadDir

func (o *Os) ReadDir(i any) ([]os.FileInfo, error)

ReadDir lists the directory contents relative to the configured WorkingDir.

func (*Os) ReadFile

func (o *Os) ReadFile(i any) (string, error)

ReadFile reads the file named by filename relative to the configured WorkingDir. It returns the contents as a string. There is an upper size limit set at 1 megabytes.

func (*Os) Stat

func (o *Os) Stat(i any) (os.FileInfo, error)

Stat returns the os.FileInfo structure describing file.

type Time

type Time struct{}

func (Time) AddDate

func (Time) AddDate(t time.Time, years, months, days int) time.Time

func (Time) AddDuration

func (Time) AddDuration(t time.Time, d time.Duration) time.Time

func (Time) Duration

func (Time) Duration(d string) (time.Duration, error)

func (Time) Format

func (Time) Format(format string, t time.Time) string

func (Time) Now

func (Time) Now() time.Time

func (Time) RFC3339

func (Time) RFC3339() string

func (Time) UTC

func (Time) UTC(t time.Time) time.Time

Jump to

Keyboard shortcuts

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