utils

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2021 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeBase64

func DecodeBase64(src []byte) ([]byte, error)

DecodeBase64 decodes the input bytes, which can accept padded or none padded format.

func DecodeBase64String

func DecodeBase64String(str string) ([]byte, error)

DecodeBase64String decodes the input string, which can accept padded or none padded format.

func EncodeBase64

func EncodeBase64(src []byte) []byte

EncodeBase64 encodes the input bytes, and then output standard format.

func EncodeBase64ToString

func EncodeBase64ToString(src []byte) string

EncodeBase64ToString encodes the input bytes, and then output standard format string.

func HandleCrash

func HandleCrash(additionalHandlers ...func(interface{}))

HandleCrash handles the crash with a default log handler.

func HandleCrashSilent

func HandleCrashSilent(additionalHandlers ...func(interface{}))

HandleCrashSilent handles the crash without the default log handler.

func MarshalJSON

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

MarshalJSON encodes the input object as JSON.

func NormalizePath

func NormalizePath(path string) (string, error)

NormalizePath returns an absolute path of given path.

func ToBool

func ToBool(i interface{}, d ...bool) bool

ToBool tries to convert an interface to `bool`.

func ToDuration added in v0.0.4

func ToDuration(i interface{}, d ...time.Duration) time.Duration

ToDuration tries to convert an interface to `time.Duration`.

func ToInt

func ToInt(i interface{}, d ...int) int

ToInt tries to convert an interface to `int`.

func ToInterfaceSlice added in v0.0.3

func ToInterfaceSlice(i interface{}) []interface{}

ToInterfaceSlice tries to convert an interface to `[]interface`.

func ToString

func ToString(i interface{}, d ...string) string

ToString tries to convert an interface to `string`.

func ToStringInterfaceMap added in v0.0.3

func ToStringInterfaceMap(i interface{}) map[string]interface{}

ToStringInterfaceMap tries to convert an interface to `map[string]interface{}`.

func ToStringSlice

func ToStringSlice(i interface{}) []string

ToStringSlice tries to convert an interface to `[]string`.

func ToStringStringMap added in v0.0.3

func ToStringStringMap(i interface{}) map[string]string

ToStringStringMap tries to convert an interface to `map[string]string`.

func TryMarshalJSON

func TryMarshalJSON(v interface{}) []byte

TryMarshalJson is the same as MarshalJSON but doesn't return error.

func TryUnmarshalJSON

func TryUnmarshalJSON(data []byte, v interface{})

TryUnmarshalJSON is the same as UnmarshalJSON but doesn't return error.

func UnmarshalJSON

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

UnmarshalJSON decodes the input JSON into the input handler.

func UnsafeBytesToString

func UnsafeBytesToString(bs []byte) string

func UnsafeStringToBytes

func UnsafeStringToBytes(s string) (bytes []byte)

Types

This section is empty.

Jump to

Keyboard shortcuts

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