util

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Default

func Default[T any](value *T, defaultValue *T) *T

func DefaultString

func DefaultString(value string, defaultValue string) string

func EnvVarCheckBool

func EnvVarCheckBool(name string) bool

func GetTrustedIP added in v0.10.0

func GetTrustedIP(r *http.Request, depth int) string

GetTrustedIP returns the trusted IP address of the client. It checks the X-Forwarded-For header first, and falls back to the RemoteAddr field of the request if the header is not present. depth is the number of proxies that the request has passed through.

func GobHash

func GobHash(objs ...any) (uint32, error)

func GobHashBytes

func GobHashBytes(objs ...any) (uint32, error)

func JsonError

func JsonError[T any](w http.ResponseWriter, statusCode int, message T)

func JsonErrors

func JsonErrors[T any](w http.ResponseWriter, statusCode int, message []T)

func JsonHash

func JsonHash(objs ...any) (uint32, error)

func JsonHashBytes

func JsonHashBytes(objs ...any) ([]byte, error)

func JsonResponse

func JsonResponse(w http.ResponseWriter, statusCode int, data any)

func ParseInt

func ParseInt(s string, def int) (int, error)

func ToBytes

func ToBytes(a any) ([]byte, error)

func WriteStatusCodeError

func WriteStatusCodeError(w http.ResponseWriter, code int)

Types

This section is empty.

Directories

Path Synopsis
tree
avl

Jump to

Keyboard shortcuts

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