utils

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 License: MPL-2.0 Imports: 13 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{}) bool

ToBool tries to convert an interface to bool value.

func ToInt

func ToInt(i interface{}) int

ToInt tries to convert an interface to int value.

func ToString

func ToString(i interface{}) string

ToString tries to convert an interface to string value.

func ToStringSlice

func ToStringSlice(i interface{}) []string

ToStringSlice tries to convert an interface to string slice.

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