convert

package
v0.0.0-...-4d33260 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromHttpResponse

func FromHttpResponse(res *http.Response, v any) error

FromHttpResponse reads the response body from the specified http response and converts it into the specified value

func ParseDuration

func ParseDuration(value string) (time.Duration, error)

func ToJsonArray

func ToJsonArray(value any) ([]any, error)

ToJsonArray converts the specified value (slice) to a json array

func ToMap

func ToMap(value any) (map[string]any, error)

Converts the specified value to a map.

func ToStringWithDefault

func ToStringWithDefault(value any, defaultValue string) string

Attempts to convert the specified value to a string, otherwise returns the default value

func ToValueWithDefault

func ToValueWithDefault[T any](ptr *T, defaultValue T) T

Converts a pointer to a value type If the ptr is nil returns default value, otherwise the value of value of the pointer

Types

This section is empty.

Jump to

Keyboard shortcuts

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