utils

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2021 License: MPL-2.0 Imports: 17 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 DeepCopyStringPointer added in v0.3.1

func DeepCopyStringPointer(s *string) *string

DeepCopyStringPointer returns a new pointer of the given string pointer.

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 HashString added in v0.2.4

func HashString(s string) int

HashString hashes a string to a unique hashcode.

crc32 returns a uint32, but for our use we need and non negative integer. Here we cast to an integer and invert it if the result is negative.

func HashStrings added in v0.2.4

func HashStrings(strings []string) string

HashStrings hashes a list of strings to a unique hashcode.

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 StringPointer added in v0.3.1

func StringPointer(s string) *string

StringPointer returns the pointer of the given string.

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 ToStringInterfaceMapSlice added in v0.3.0

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

ToStringInterfaceMapSlice 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 ToStringStringMapSlice added in v0.3.0

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

ToStringStringMapSlice 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