conv

package
v1.2.10 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimeFormatUnixTimestamp                 = "unix-timestamp"
	TimeFormatUnixMilliTimestamp            = "unix-milli-timestamp"
	TimeFormatUnixTimestampString           = "unix-timestamp-string"
	TimeFormatUnixMilliTimestampString      = "unix-milli-timestamp-string"
	TimeFormatFloatUnixTimestamp            = "float-unix-timestamp"
	TimeFormatFloatUnixMilliTimestamp       = "float-unix-milli-timestamp"
	TimeFormatFloatUnixTimestampString      = "float-unix-timestamp-string"
	TimeFormatFloatUnixMilliTimestampString = "float-unix-milli-timestamp-string"
)

Variables

This section is empty.

Functions

func BinaryUnmarshalerHookFunc added in v1.2.3

func BinaryUnmarshalerHookFunc() mapstructure.DecodeHookFuncType

BinaryUnmarshalerHookFunc returns a DecodeHookFunc that applies strings to the UnmarshalBinary function, when the target type implements the encoding.BinaryUnmarshaler interface

func DecodeQuery added in v1.2.3

func DecodeQuery(query string, dst interface{}, config *mapstructure.DecoderConfig, fs ...mapstructure.DecodeHookFunc) error

DecodeQuery takes an input query string and uses reflection to translate it to the dst structure. dst must be a pointer to a map or struct.

func DecodeURLValues added in v1.2.3

func DecodeURLValues(u url.Values, dst interface{}, config *mapstructure.DecoderConfig, fs ...mapstructure.DecodeHookFunc) error

DecodeURLValues takes an input url.Values and uses reflection to translate it to the dst structure. dst must be a pointer to a map or struct.

func DefaultDecodeHookFuncs added in v1.2.3

func DefaultDecodeHookFuncs() []mapstructure.DecodeHookFunc

func JSON

func JSON[sT any, dT any](src sT, dst *dT) error

func StringToBaseTypeHookFunc added in v1.2.3

func StringToBaseTypeHookFunc(fv reflect.Value, tv reflect.Value) (interface{}, error)

func StringToTimeHookFunc added in v1.2.3

func StringToTimeHookFunc(f reflect.Type, t reflect.Type, data interface{}) (interface{}, error)

StringToTimeHookFunc returns a DecodeHookFunc that converts strings to time.Time.

func URLValuesHookFunc added in v1.2.3

Types

type Time added in v1.2.3

type Time struct {
	time.Time
	Format string
}

func (Time) MarshalJSON added in v1.2.3

func (t Time) MarshalJSON() ([]byte, error)

func (*Time) UnmarshalJSON added in v1.2.3

func (t *Time) UnmarshalJSON(raw []byte) error

Jump to

Keyboard shortcuts

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