formutil

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeBool

func DecodeBool(key string, values []string) (bool, error)

DecodeBool decodes a boolean value from form values.

func DecodeBoolPtr

func DecodeBoolPtr(key string, values []string) (*bool, error)

DecodeBoolPtr decodes a boolean value and returns a pointer to it.

func DecodeBytes

func DecodeBytes(key string, values []string) ([]byte, error)

DecodeBytes decodes a base64-encoded string into a byte slice.

func DecodeFloat

func DecodeFloat[T ~float64 | ~float32](key string, values []string) (T, error)

DecodeFloat decodes a floating-point value from form values.

func DecodeFloatPtr

func DecodeFloatPtr[T ~float64 | ~float32](key string, values []string) (*T, error)

DecodeFloatPtr decodes a floating-point value and returns a pointer to it.

func DecodeInt

func DecodeInt[T ~int64 | ~int32 | ~int16 | ~int8 | ~int](key string, values []string) (T, error)

DecodeInt decodes a signed integer value from form values.

func DecodeIntPtr

func DecodeIntPtr[T ~int64 | ~int32 | ~int16 | ~int8 | ~int](key string, values []string) (*T, error)

DecodeIntPtr decodes a signed integer value and returns a pointer to it.

func DecodeJSON

func DecodeJSON[T any](key string, values []string) (T, error)

DecodeJSON decodes a JSON-encoded value into the target type.

func DecodeList

func DecodeList[T any](key string, values []string, fn Decoder[T]) ([]T, error)

DecodeList decodes multiple form values into a slice using the provided decoder.

func DecodeString

func DecodeString(key string, values []string) (string, error)

DecodeString decodes a string value from form values.

func DecodeStringPtr

func DecodeStringPtr(key string, values []string) (*string, error)

DecodeStringPtr decodes a string value and returns a pointer to it.

func DecodeUint

func DecodeUint[T ~uint64 | ~uint32 | ~uint16 | ~uint8 | ~uint](key string, values []string) (T, error)

DecodeUint decodes an unsigned integer value from form values.

func DecodeUintPtr

func DecodeUintPtr[T ~uint64 | ~uint32 | ~uint16 | ~uint8 | ~uint](key string, values []string) (*T, error)

DecodeUintPtr decodes an unsigned integer value and returns a pointer to it.

func EncodeBool

func EncodeBool(m url.Values, key string, val bool) error

EncodeBool encodes a boolean value into url.Values.

func EncodeBoolPtr

func EncodeBoolPtr(m url.Values, key string, val *bool) error

EncodeBoolPtr encodes a boolean pointer value into url.Values. If the pointer is nil, the field is omitted.

func EncodeBytes

func EncodeBytes(m url.Values, key string, val []byte) error

EncodeBytes encodes a byte slice into url.Values using base64 encoding.

func EncodeFloat

func EncodeFloat[T ~float64 | ~float32](m url.Values, key string, val T) error

EncodeFloat encodes a floating-point value into url.Values.

func EncodeFloatPtr

func EncodeFloatPtr[T ~float64 | ~float32](m url.Values, key string, val *T) error

EncodeFloatPtr encodes a floating-point pointer value into url.Values. If the pointer is nil, the field is omitted.

func EncodeInt

func EncodeInt[T ~int64 | ~int32 | ~int16 | ~int8 | ~int](m url.Values, key string, val T) error

EncodeInt encodes a signed integer value into url.Values.

func EncodeIntPtr

func EncodeIntPtr[T ~int64 | ~int32 | ~int16 | ~int8 | ~int](m url.Values, key string, val *T) error

EncodeIntPtr encodes a signed integer pointer value into url.Values. If the pointer is nil, the field is omitted.

func EncodeJSON

func EncodeJSON[T any](m url.Values, key string, val T) error

EncodeJSON encodes a value into JSON and stores it in url.Values.

func EncodeList

func EncodeList[T any](m url.Values, key string, values []T, fn Encoder[T]) error

EncodeList encodes a list of values into url.Values using the provided encoder function. Each element in the slice is encoded independently.

func EncodeString

func EncodeString(m url.Values, key string, val string) error

EncodeString encodes a string value into url.Values.

func EncodeStringPtr

func EncodeStringPtr(m url.Values, key string, val *string) error

EncodeStringPtr encodes a string pointer value into url.Values. If the pointer is nil, the field is omitted.

func EncodeUint

func EncodeUint[T ~uint64 | ~uint32 | ~uint16 | ~uint8 | ~uint](m url.Values, key string, val T) error

EncodeUint encodes an unsigned integer value into url.Values.

func EncodeUintPtr

func EncodeUintPtr[T ~uint64 | ~uint32 | ~uint16 | ~uint8 | ~uint](m url.Values, key string, val *T) error

EncodeUintPtr encodes an unsigned integer pointer value into url.Values. If the pointer is nil, the field is omitted.

Types

type Decoder

type Decoder[T any] func(key string, values []string) (T, error)

Decoder defines a generic decoder function for a single form value.

type Encoder

type Encoder[T any] func(m url.Values, key string, val T) error

Encoder is a function type that encodes a value into url.Values.

Jump to

Keyboard shortcuts

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