vegeTools

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2023 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CertName = "cert.pem"
	KeyName  = "key.pem"
)

Functions

func CheckBySalt

func CheckBySalt(checked, hash, salt string) bool

CheckBySalt check HashBySalt

func GetLocalIpv4ByUdp

func GetLocalIpv4ByUdp() (ip string, err error)

GetLocalIpv4ByUdp 获取 localIp by net.Dial("udp", "8.8.8.8:53")

func GetLocalIpv4List

func GetLocalIpv4List() ([]string, error)

GetLocalIpv4List 获取所有非lo的网卡ip

func GetMacMap

func GetMacMap() map[string]string

GetMacMap 获取本机的MAC地址

func GetPublicIp_ipsb

func GetPublicIp_ipsb() (ip string, err error)

GetPublicIp_ipsb curl ip.sb 的响应值 被GWF服务器不可用

func HashBySalt

func HashBySalt(ps, salt string) string

HashBySalt hmac sha2 and salt make hash

func IfEx

func IfEx[T any](boolExpr bool, trueReturn, falseReturn T) T

IfEx if 实现的三元表达式

func JsonMarshal

func JsonMarshal(v any) ([]byte, error)

func JsonMarshalToString

func JsonMarshalToString(v any) (string, error)

func JsonUnmarshal

func JsonUnmarshal(data []byte, v any) error

func JsonUnmarshalFromString

func JsonUnmarshalFromString(str string, v any) error

func MapClear

func MapClear[M ~map[K]V, K comparable, V any](m M)

MapClear removes all entries from m, leaving it empty.

func MapClone

func MapClone[M ~map[K]V, K comparable, V any](m M) M

MapClone returns a copy of m. This is a shallow clone: the new keys and values are set using ordinary assignment.

func MapCopy

func MapCopy[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2)

MapCopy copies all key/value pairs in src adding them to dst. When a key in src is already present in dst, the value in dst will be overwritten by the value associated with the key in src.

func MapDeleteFunc

func MapDeleteFunc[M ~map[K]V, K comparable, V any](m M, del func(K, V) bool)

MapDeleteFunc deletes any key/value pairs from m for which del returns true.

func MapEqual

func MapEqual[M1, M2 ~map[K]V, K, V comparable](m1 M1, m2 M2) bool

MapEqual reports whether two maps contain the same key/value pairs. MapValues are compared using ==.

func MapEqualFunc

func MapEqualFunc[M1 ~map[K]V1, M2 ~map[K]V2, K comparable, V1, V2 any](m1 M1, m2 M2, eq func(V1, V2) bool) bool

MapEqualFunc is like MapEqual, but compares values using eq. MapKeys are still compared with ==.

func MapKeys

func MapKeys[M ~map[K]V, K comparable, V any](m M) []K

MapKeys returns the keys of the map m. The keys will be in an indeterminate order.

func MapToObj

func MapToObj(m map[string]any, obj any) error

MapToObj map[string] interface ---> obj

func MapValues

func MapValues[M ~map[K]V, K comparable, V any](m M) []V

MapValues returns the values of the map m. The values will be in an indeterminate order.

func ObjToMap

func ObjToMap(obj any, m *map[string]any) error

ObjToMap obj ---> map[string] interface

func PanicIfErr

func PanicIfErr(err error)

func PanicToErr

func PanicToErr(fn func()) (err error)

func RandBytesMask

func RandBytesMask(n int) []byte

func RandStringMask

func RandStringMask(n int) string

func TlsCertGenerateToFile

func TlsCertGenerateToFile(path string) error

TlsCertGenerateToFile 生成自签tls证书 cert.pem key.pem 到指定文件夹中

func TlsCertGenerateToMap

func TlsCertGenerateToMap() (cert map[string]string, err error)

TlsCertGenerateToMap 生成自签tls证书 cert.pem key.pem 到map

Types

type Quit

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

func NewQuit

func NewQuit() *Quit

func (*Quit) Close

func (q *Quit) Close() error

func (*Quit) WaitCloseWithFn

func (q *Quit) WaitCloseWithFn(fn func())

type Rate

type Rate struct {
	ratelimit.Limiter
}

Rate 基于 "go.uber.org/ratelimit" 的漏桶算法限流器的封装

func NewRateLeakyBucket

func NewRateLeakyBucket(n int64) *Rate

func (*Rate) RateLimitDo

func (r *Rate) RateLimitDo(fn func())

Jump to

Keyboard shortcuts

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