utils

package
v0.0.0-...-4593788 Latest Latest
Warning

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

Go to latest
Published: May 30, 2025 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterOptionAbsent

func FilterOptionAbsent[T any](item mo.Option[T], _ int) bool

func FilterOptionPresent

func FilterOptionPresent[T any](item mo.Option[T], _ int) bool

func FromMap

func FromMap[T any, MK comparable, MV any](m map[MK]MV) (*T, error)

func FromString

func FromString[T any](str string) (T, error)

func FromStringOrEmpty

func FromStringOrEmpty[T any](str string) T

func GetByJSONPath

func GetByJSONPath[T any](input any, template string) T

func GetByJSONPathWithoutConvert

func GetByJSONPathWithoutConvert(input any, template string) (string, error)

func IsNumber

func IsNumber(str string) bool

func MapOptionMust

func MapOptionMust(item mo.Option[error], _ int) error

func MapOptionOrEmpty

func MapOptionOrEmpty[T any](item mo.Option[T], _ int) T

func MapOptionsPresent

func MapOptionsPresent[T any](items []mo.Option[T]) []T

func NewJSONResponseError

func NewJSONResponseError(statusCode int, responseBody io.Reader) mo.Result[*JSONResponseError]

func NewTextResponseError

func NewTextResponseError(statusCode int, responseBody io.Reader) mo.Result[*TextResponseError]

func ReadAsJSON

func ReadAsJSON(reader io.Reader) (*bytes.Buffer, map[string]any, error)

func ReadAsJSONWithClose

func ReadAsJSONWithClose(readCloser io.ReadCloser) (*bytes.Buffer, map[string]any, error)

func ResultToOption

func ResultToOption[T any](item mo.Result[T]) mo.Option[T]

Types

type JSONResponseError

type JSONResponseError struct {
	StatusCode int    `json:"status_code"`
	Message    string `json:"message"`
	// contains filtered or unexported fields
}

func (*JSONResponseError) Error

func (r *JSONResponseError) Error() string

type TextResponseError

type TextResponseError struct {
	StatusCode int    `json:"status_code"`
	Body       string `json:"body"`
}

func (*TextResponseError) Error

func (r *TextResponseError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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