util

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DateType       = reflect.TypeOf(DateTime{})
	JSONNumberType = reflect.TypeOf(json.Number(""))
)

Functions

func DateTimeDecodeHook

func DateTimeDecodeHook(layout string, location *time.Location) mapstructure.DecodeHookFuncType

DateTimeDecodeHook parses date time that's supplied in a non-standard layout if layout does not contain a time zone, a location need be provided

func Filter

func Filter(src []map[string]interface{}, fields []string)

Filter removes fields that are not part of the list

func GetStructTagNames

func GetStructTagNames(val any, tag string) []string

GetStructTags returns list of names for a given struct tag

func JSONNumberDecodeHook

func JSONNumberDecodeHook(srcT, dstT reflect.Type, data interface{}) (interface{}, error)

JSONNumberDecodeHook helps mapstructure to deal with

func Remap

func Remap(src []map[string]interface{}, fieldMap []FieldRemap) error

Remap is used to rename map keys in-place

Types

type DateTime

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

DateTime is used by some API services to represent date and/or time in a non-standard manners, that may also be

func NewDateTime

func NewDateTime(tm time.Time, layout string) DateTime

NewDateTime creates new date time object

func (DateTime) MarshalJSON

func (d DateTime) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (DateTime) String

func (d DateTime) String() string

String returns string representation in the target layout

func (*DateTime) Time

func (d *DateTime) Time() time.Time

type FieldRemap

type FieldRemap struct {
	From, To string
}

func NewRemapFromPairs

func NewRemapFromPairs(src []string) ([]FieldRemap, error)

NewRemapFromPairs takes an array of srcKey=dstKey pairs and converts them into FieldRemap array

type URL

type URL url.URL

func (*URL) MarshalJSON

func (u *URL) MarshalJSON() ([]byte, error)

func (*URL) String

func (u *URL) String() string

func (*URL) URL

func (u *URL) URL() *url.URL

func (*URL) UnmarshalJSON

func (u *URL) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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