utils

package
v1.6.8 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrGjsonNotFound  = errors.New("specified path does not exist")
	ErrGjsonWrongType = errors.New("wrong type")
)
View Source
var (
	HttpClientSkipTlsVerify *http.Client
	HttpClient              *http.Client
)
View Source
var (
	Json = jsoniter.ConfigCompatibleWithStandardLibrary

	DNSServers = []string{"1.1.1.1:53", "223.5.5.5:53"}
)

Functions

func BinaryToIPString

func BinaryToIPString(b []byte) string

func ConvertSeq added in v1.5.8

func ConvertSeq[T, U any](seq iter.Seq[T], f func(e T) U) iter.Seq[U]

func GenerateRandomString

func GenerateRandomString(n int) (string, error)

func GetIPFromHeader

func GetIPFromHeader(headerValue string) (string, error)

func GjsonGet

func GjsonGet(json []byte, path string) (gjson.Result, error)

func GjsonIter added in v1.6.0

func GjsonIter(json string) (iter.Seq2[string, string], error)

func IPDesensitize

func IPDesensitize(ipAddr string) string

func IPStringToBinary

func IPStringToBinary(ip string) ([]byte, error)

func IfOr

func IfOr[T any](a bool, x, y T) T

func IfOrFn

func IfOrFn[T any](a bool, x, y func() T) T

func IsFileExists

func IsFileExists(path string) bool

func Itoa

func Itoa[T constraints.Integer](i T) string

func MapValuesToSlice added in v1.4.0

func MapValuesToSlice[Map ~map[K]V, K comparable, V any](m Map) []V

func SplitIPAddr

func SplitIPAddr(v4v6Bundle string) (string, string, string)

SplitIPAddr 传入/分割的v4v6混合地址,返回v4和v6地址与有效地址

func Uint64SubInt64

func Uint64SubInt64(a uint64, b int64) uint64

func Unique added in v1.4.0

func Unique[T comparable](s []T) []T

Types

type GinCustomWriter added in v1.5.10

type GinCustomWriter struct {
	gin.ResponseWriter
	// contains filtered or unexported fields
}

func NewGinCustomWriter added in v1.5.10

func NewGinCustomWriter(c *gin.Context, code int) *GinCustomWriter

func (*GinCustomWriter) WriteHeader added in v1.5.10

func (w *GinCustomWriter) WriteHeader(code int)

type RequestWrapper

type RequestWrapper struct {
	// contains filtered or unexported fields
}

func NewRequestWrapper

func NewRequestWrapper(req *http.Request, writer http.ResponseWriter) (*RequestWrapper, error)

func (*RequestWrapper) Close

func (rw *RequestWrapper) Close() error

func (*RequestWrapper) Read

func (rw *RequestWrapper) Read(p []byte) (int, error)

func (*RequestWrapper) Write

func (rw *RequestWrapper) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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