Categorygithub.com/jerbe/go-utils
modulepackage
1.0.2
Repository: https://github.com/jerbe/go-utils.git
Documentation: pkg.go.dev

# README

GO-Utils The Utility package for golang

install

go get github.com/jerbe/go-utils

how to use

import (
	"fmt"
	
    utils "github.com/jerbe/go-utils"
)


func main() {
	// print the local host name
    fmt.Println(utils.GetHostname())   
	// >> jerbe-mac
	
	// print local IP
	fmt.Println(utils.GetLocalIPv4())
	// >> 192.168.31.100
	
	...
}

# Functions

AtomicAddInt 原子增加.
AtomicCompareAndSwapInt 原子对比并替换.
AtomicLoadInt 原子加载.
AtomicStoreInt 原子存储.
AtomicSwapInt 原子替换.
ContextIsDone 判断上下文(Context)是否已经结束,完成.
EQ 等于.
EqualAll 判断target跟targets内的所有项与obj是否相等,如果全部target都与obj相等 如果obj与target跟targets里面的所有数据都相等,则返回true,如果有其中一项不相等,则返回false.
GetClientIP 获取用户的真实IP.
GT 大于.
GTE 大于等于.
Hostname 获取本机名.
In 判断obj是否与target或者targets内的某个元素相等 如果 obj 等于 target 或者等于 targets 其中一项,则返回true 如果没匹配到其中一项,则返回false.
Int16Between dest在指定范围内 是一个闭区间 from <= dest <= to.
No description provided by the author
Int16Sort 排序整型 返回的数据总是 a <= b.
Int32Between dest在指定范围内 是一个闭区间 from <= dest <= to.
No description provided by the author
Int32Sort 排序整型 返回的数据总是 a <= b.
Int64Between dest在指定范围内 是一个闭区间 from <= dest <= to.
No description provided by the author
Int64Sort 排序整型 返回的数据总是 a <= b.
Int8Between dest在指定范围内 是一个闭区间 from <= dest <= to.
No description provided by the author
Int8Sort 排序整型 返回的数据总是 a <= b.
IntBetween dest在指定范围内 是一个闭区间 from <= dest <= to.
IntBitCheck 检测某一位的数值是否为1,从右到左方向.
IntBitClear 清理设置某一位的数值为0,从右到左方向.
IntBitSet 填充设置某一位的数值为1,从右到左方向.
No description provided by the author
IntSort 排序整型 返回的数据总是 a <= b.
IsNil 检测是否是真nil值.
LocalIPv4 获取当前IPv4地址.
LocalIPv6 获取当前IPv6地址.
LT 小于.
LTE 小于等于.
MasterIP 获取连接互联网的主IP地址.
MD5 封装的一个MD5加密字节组.
MD5String 封装的一个MD5加密字符串的方法.
No description provided by the author
No description provided by the author
NewLimiter 返回新的限制器.
NewPubSub 新生成一个发布/订阅器.
SliceUnique 将切片进行唯一归类.
StringLen 返回字符串的长度,因为中文需要3个字节(byte),所以,我们使用rune来代替.
StringTrim 根据指定的start跟count,裁剪出需要的字符串 支持汉字何emoji表情等多字节字符.
TypeEqual 判断两个对象的类型是否相等.

# Constants

BreakerStateClose 关闭状态,说明服务可用.
BreakerStateHalfOpen 半开状态,说明已经经过"打开状态".
BreakerStateOpen 打开状态,说明服务不能用.

# Variables

* @author : Jerbe - The porter from Earth @time : 2023/10/6 16:12 @describe : */.

# Structs

No description provided by the author
Breaker 断路器.
Limiter 数量限定器.
PubSub 发布/订阅器.
SubSignal 订阅信号.

# Type aliases

BreakerRunFunc 断路器执行方法.
BreakerState 断路器状态.
No description provided by the author