util

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2024 License: Apache-2.0 Imports: 18 Imported by: 2

Documentation

Index

Constants

View Source
const (
	TimeLayout   = "2006-01-02 15:04:05"
	TimeLayoutMs = "2006-01-02 15:04:05.000"
)

Variables

This section is empty.

Functions

func First

func First[T any](defaultArg T, args []T) T

func GetBoolValue

func GetBoolValue(m map[string]any, key string) (bool, bool)

func GetFloatValue

func GetFloatValue(m map[string]any, key string) (float64, bool)

func GetIntValue

func GetIntValue(m map[string]any, key string) (int, bool)

func GetInterfaceSlice

func GetInterfaceSlice(m map[string]any, key string) ([]any, bool)

func GetStringSlice

func GetStringSlice(m map[string]any, key string) ([]string, bool)

func GetStringValue

func GetStringValue(m map[string]any, key string) (string, bool)

func HttpDelete added in v1.5.0

func HttpDelete(url string, params any, opts ...RequestOption) ([]byte, error)

func HttpDeleteWith added in v1.5.0

func HttpDeleteWith[T RespData](url string, params any, opts ...RequestOption) (T, error)

func HttpGet added in v1.5.0

func HttpGet(url string, params map[string]string, opts ...RequestOption) ([]byte, error)

func HttpGetWith added in v1.5.0

func HttpGetWith[T RespData](url string, params map[string]string, opts ...RequestOption) (T, error)

func HttpPost added in v1.5.0

func HttpPost(url string, params any, opts ...RequestOption) ([]byte, error)

func HttpPostWith added in v1.5.0

func HttpPostWith[T RespData](url string, params any, opts ...RequestOption) (T, error)

func HttpPut added in v1.5.0

func HttpPut(url string, params any, opts ...RequestOption) ([]byte, error)

func HttpPutWith added in v1.5.0

func HttpPutWith[T RespData](url string, params any, opts ...RequestOption) (T, error)

func JsonParse

func JsonParse[T any](data []byte) (T, error)

func JsonString

func JsonString(data any) string

func Max

func Max[T int | int32 | int64 | float32 | float64](a, b T) T

func Min

func Min[T int | int32 | int64 | float32 | float64](a, b T) T

func PathGlobPattern

func PathGlobPattern(pattern string) ([]string, error)

func RandStr

func RandStr(ns ...int) string

func ReadFile

func ReadFile(path string) ([]byte, error)

func TailFile added in v1.5.0

func TailFile(ctx context.Context, path string, lines chan<- string) error

func UUID

func UUID(ns ...int) string

func WalkPath

func WalkPath(path string, wildcards ...string) ([]string, error)

func WriteFile

func WriteFile(path string, buf []byte) error

Types

type RequestOption added in v1.5.2

type RequestOption struct {
	Http3      bool
	Token      string
	CaCertPath string
	Headers    map[string]string
}

type RespData added in v1.5.0

type RespData interface {
	any | map[string]any
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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