Documentation
¶
Index ¶
- Constants
- Variables
- func Abs(x int) int
- func ArrayFilter[T any](arr []T, f func(T) bool) []T
- func ArrayMap[T any, R any](arr []T, f func(T) R) []R
- func GetAvaliablePort() (int, error)
- func GetCPUInfo() (*[]CPUInfo, error)
- func GetCPUUsage() ([]float64, error)
- func GetCPUUsageTotal() (float64, error)
- func GetCaptchaMethodKey(otype string, method string) string
- func GetConfigInteger(name string) int
- func GetConfigString(name string) string
- func GetContext() c.Context
- func GetDiskUsage() (float64, uint64, uint64, error)
- func GetInterfaceType(i interface{}) int
- func GetMaxContainer() int
- func GetMemUsage() (float64, uint64, uint64, error)
- func GetNetUsage() (uint64, uint64, error)
- func GetNetUsagePercent() (float64, float64, error)
- func GetProcessInfo() (*[]ProcessInfo, error)
- func HandleSensitiveString(src string) string
- func Hash2Int(src string) int
- func HttpGet(url string, data interface{}) (int, string, error)
- func HttpPayloadMultipartFile(filename string, file io.Reader) httpPayloadMultipartFile
- func HttpPostJson(url string, data interface{}) (int, string, error)
- func InitServerConfig()
- func Md5(src string) string
- func ParseIpFromStr(ip string) int
- func Random(min int, max int) int
- func RandomStr(len int) string
- func SendAndParse[T any](method string, url string, options ...HttpOptions) (T, error)
- func SendGetAndParse[T any](url string, options ...HttpOptions) (T, error)
- func SendGetAsync(url string, final func(io.ReadCloser, *ResponseHeader, error), ...)
- func SendPostAndParse[T any](url string, options ...HttpOptions) (T, error)
- func SendPostAsync(url string, final func(io.ReadCloser, *ResponseHeader, error), ...)
- func StringJoin(strs ...string) string
- func TimeoutWrapper(timeout time.Duration, success_chan chan bool) bool
- type CPUInfo
- type Compareable
- type HighGranularityMutex
- type HttpOptions
- func HttpHeader(header map[string]string) HttpOptions
- func HttpNoRedirect() HttpOptions
- func HttpParams(params map[string]string) HttpOptions
- func HttpPayload(payload map[string]string) HttpOptions
- func HttpPayloadJson(payload interface{}) HttpOptions
- func HttpPayloadText(payload string) HttpOptions
- func HttpProxy(proxy string, user string, password string) HttpOptions
- func HttpPyloadMultipart(payload map[string]string, files ...httpPayloadMultipartFile) HttpOptions
- func HttpTimeout(timeout int64) HttpOptions
- func HttpWithDirectReferer() HttpOptions
- func HttpWithRandomUA() HttpOptions
- func HttpWithRetCode(retCode *int) HttpOptions
- type ProcessInfo
- type ResponseHeader
- func NewResponseHeader(header http.Header) *ResponseHeader
- func SendDelete(url string, options ...HttpOptions) ([]byte, *ResponseHeader, error)
- func SendGet(url string, options ...HttpOptions) ([]byte, *ResponseHeader, error)
- func SendPost(url string, options ...HttpOptions) ([]byte, *ResponseHeader, error)
- func SendPut(url string, options ...HttpOptions) ([]byte, *ResponseHeader, error)
- type Tree
- func (t *Tree[K, V]) AddNode(key K, value *V)
- func (t *Tree[K, V]) AddParent(key K, value *V)
- func (t *Tree[K, V]) AddToParent(parent_id K, key K, value *V) error
- func (t *Tree[K, V]) CheckIfParent(parent_id K, client_id K) bool
- func (t *Tree[K, V]) GetAllChildren() map[K]*V
- func (t *Tree[K, V]) GetNode(id K) *Tree[K, V]
- func (t *Tree[K, V]) Remove(key K)
- func (t *Tree[K, V]) WalkReverse(cb func(K, *V))
Constants ¶
const ( VAL_TYPE_DEFAULT = 0x0 VAL_TYPE_INT = 0x1 VAL_TYPE_STRING = 0x2 VAL_TYPE_INTERFACE_ARRAY = 0x3 VAL_TYPE_STRING_TO_INTERFACE = 0x4 VAL_TYPE_JSON_NUMBER = 0x5 //float64 VAL_TYPE_FLOAT64 = 0x5 )
Variables ¶
var (
ErrTreeNotFoundParent = errors.New("not found parent node")
)
Functions ¶
func GetAvaliablePort ¶
func GetCPUInfo ¶
func GetCPUUsage ¶
func GetCPUUsageTotal ¶
func GetCaptchaMethodKey ¶
根据验证码类型与操作名获取key
func GetConfigInteger ¶
func GetConfigString ¶
func GetContext ¶
func GetInterfaceType ¶
func GetInterfaceType(i interface{}) int
func GetMaxContainer ¶
func GetMaxContainer() int
func GetNetUsage ¶
ret: 1. recv bytes, 2. sent bytes, 3. error
func GetNetUsagePercent ¶
func GetProcessInfo ¶
func GetProcessInfo() (*[]ProcessInfo, error)
func HandleSensitiveString ¶
func HttpGet ¶
https request get, data is a struct which will be converted to urlencoded query string example:
type User struct { Name string `json:"name"` }
httpsGet("http://www.example.com?name=hello", &User{})
func HttpPostJson ¶
https request post json data
func InitServerConfig ¶
func InitServerConfig()
func SendAndParse ¶
func SendAndParse[T any](method string, url string, options ...HttpOptions) (T, error)
func SendGetAndParse ¶
func SendGetAndParse[T any](url string, options ...HttpOptions) (T, error)
func SendGetAsync ¶
func SendGetAsync(url string, final func(io.ReadCloser, *ResponseHeader, error), options ...HttpOptions)
SendGetAsync is not a real async function, it only open the connection and pass the reader to user, to close the connection, the final function should be passed, and user will not be nervous about the connection leak
func SendPostAndParse ¶
func SendPostAndParse[T any](url string, options ...HttpOptions) (T, error)
func SendPostAsync ¶
func SendPostAsync(url string, final func(io.ReadCloser, *ResponseHeader, error), options ...HttpOptions)
SendPostAsync is not a real async function, it only open the connection and pass the reader to user, to close the connection, the final function should be passed, and user will not be nervous about the connection leak
func StringJoin ¶
Types ¶
type Compareable ¶
type HighGranularityMutex ¶
type HighGranularityMutex[K Compareable] struct { // contains filtered or unexported fields }
func NewHighGranularityMutex ¶
func NewHighGranularityMutex[K Compareable]() *HighGranularityMutex[K]
func (*HighGranularityMutex[K]) Lock ¶
func (c *HighGranularityMutex[K]) Lock(id K)
func (*HighGranularityMutex[K]) Unlock ¶
func (c *HighGranularityMutex[K]) Unlock(id K)
type HttpOptions ¶
type HttpOptions struct { Type string Value interface{} }
func HttpHeader ¶
func HttpHeader(header map[string]string) HttpOptions
func HttpNoRedirect ¶
func HttpNoRedirect() HttpOptions
func HttpParams ¶
func HttpParams(params map[string]string) HttpOptions
which is used for params with in url
func HttpPayload ¶
func HttpPayload(payload map[string]string) HttpOptions
which is used for POST method only
func HttpPayloadJson ¶
func HttpPayloadJson(payload interface{}) HttpOptions
which is used for POST method only
func HttpPayloadText ¶
func HttpPayloadText(payload string) HttpOptions
which is used for POST method only
func HttpPyloadMultipart ¶
func HttpPyloadMultipart(payload map[string]string, files ...httpPayloadMultipartFile) HttpOptions
func HttpWithDirectReferer ¶
func HttpWithDirectReferer() HttpOptions
func HttpWithRandomUA ¶
func HttpWithRandomUA() HttpOptions
func HttpWithRetCode ¶
func HttpWithRetCode(retCode *int) HttpOptions
type ProcessInfo ¶
type ResponseHeader ¶
func NewResponseHeader ¶
func NewResponseHeader(header http.Header) *ResponseHeader
func SendDelete ¶
func SendDelete(url string, options ...HttpOptions) ([]byte, *ResponseHeader, error)
func SendGet ¶
func SendGet(url string, options ...HttpOptions) ([]byte, *ResponseHeader, error)
func SendPost ¶
func SendPost(url string, options ...HttpOptions) ([]byte, *ResponseHeader, error)
func SendPut ¶
func SendPut(url string, options ...HttpOptions) ([]byte, *ResponseHeader, error)
func (*ResponseHeader) FindContentEncoding ¶
func (r *ResponseHeader) FindContentEncoding() string
func (*ResponseHeader) FindContentLength ¶
func (r *ResponseHeader) FindContentLength() int64
func (*ResponseHeader) FindContentType ¶
func (r *ResponseHeader) FindContentType() string
func (*ResponseHeader) FindKey ¶
func (r *ResponseHeader) FindKey(key string) string
func (*ResponseHeader) ToString ¶
func (r *ResponseHeader) ToString() string
type Tree ¶
type Tree[K Compareable, V any] struct { // contains filtered or unexported fields }
Not thread safety
func NewTree ¶
func NewTree[K, V Compareable]() *Tree[K, V]
func (*Tree[K, V]) AddParent ¶
func (t *Tree[K, V]) AddParent(key K, value *V)
add parent if you want to add parent to a relative root node
func (*Tree[K, V]) AddToParent ¶
add to parent
func (*Tree[K, V]) CheckIfParent ¶
check if the node holds parent_id as key is parent of node holds client_id as key
func (*Tree[K, V]) GetAllChildren ¶
func (t *Tree[K, V]) GetAllChildren() map[K]*V
func (*Tree[K, V]) WalkReverse ¶
func (t *Tree[K, V]) WalkReverse(cb func(K, *V))
Walk tree from bottom leaf to root