Documentation ¶
Index ¶
- Variables
- func B2S(b []byte) string
- func B64Decode(s string) []byte
- func B64Encode(b []byte) string
- func B64UrlDecode(s string) []byte
- func B64UrlEncode(b []byte) string
- func BeginOfDay(t time.Time) time.Time
- func BeginOfHour(t time.Time) time.Time
- func BeginOfLastMonth(t time.Time) time.Time
- func BeginOfLastWeek(t time.Time) time.Time
- func BeginOfMinute(t time.Time) time.Time
- func BeginOfMonth(t time.Time) time.Time
- func BeginOfNextMonth(t time.Time) time.Time
- func BeginOfNextWeek(t time.Time) time.Time
- func BeginOfSecond(t time.Time) time.Time
- func BeginOfTomorrow(t time.Time) time.Time
- func BeginOfWeek(t time.Time) time.Time
- func BeginOfYear(t time.Time) time.Time
- func BeginOfYesterday(t time.Time) time.Time
- func CPUTicks() int64
- func CSTLayoutString() string
- func CSTLayoutStringToUnix(cstLayoutString string) (int64, error)
- func CallPath() string
- func DaysInYear(year int) int
- func EndOfDay(t time.Time) time.Time
- func EndOfHour(t time.Time) time.Time
- func EndOfLastMonth(t time.Time) time.Time
- func EndOfLastWeek(t time.Time) time.Time
- func EndOfMinute(t time.Time) time.Time
- func EndOfMonth(t time.Time) time.Time
- func EndOfNextMonth(t time.Time) time.Time
- func EndOfNextWeek(t time.Time) time.Time
- func EndOfSecond(t time.Time) time.Time
- func EndOfTomorrow(t time.Time) time.Time
- func EndOfWeek(t time.Time) time.Time
- func EndOfYear(t time.Time) time.Time
- func EndOfYesterday(t time.Time) time.Time
- func Executable(evalSymlinks ...bool) string
- func ExecutableDir(evalSymlinks ...bool) string
- func Extract(hostPort string, lis net.Listener) (string, error)
- func ExtractHostPort(addr string) (host string, port uint64, err error)
- func FastIntn(n int) int
- func FastRand() uint32
- func FastRandBytes(n int) []byte
- func FastRandn(n uint32) uint32
- func FormatAmount(amount float64) int
- func FormatResUrl(dfs, url string) string
- func GMTLayoutString() string
- func GetMonthDays(t time.Time) int
- func GetRealIP(r *http.Request) (ip string)
- func Hostname() string
- func InSliceInt(s int, ss []int) bool
- func InSliceStr(s string, ss []string) bool
- func InterfaceAddrs(v ...string) (map[string][]net.IP, error)
- func InternalIP(dstAddr, network string) string
- func InternalIPv4() string
- func InternalIPv6() string
- func IsLeapYear(year int) bool
- func JoinBytes(b ...[]byte) []byte
- func LeftPad(s, pad string, n int) string
- func LeftPadBytes(b, pad []byte, n int) []byte
- func LocalIP() string
- func LocalIPv4s() (ips []string)
- func MapBuildQuery(m map[string]any) string
- func MustInt(v any) int
- func MustString(v any, timeLayout ...string) string
- func NanoTime() int64
- func NewRand(seed ...int64) *rand.Rand
- func Pad(s, pad string, n int) string
- func PadBytes(s, pad []byte, n int) []byte
- func ParseAmount(amount int) float64
- func ParseCSTInLocation(date string) (time.Time, error)
- func ParseGMTInLocation(date string) (time.Time, error)
- func Port(lis net.Listener) (int, bool)
- func RandBytes(n int) ([]byte, error)
- func RandHex(nHalf int) string
- func RandInt(min, max int) int
- func RandString(n int) string
- func RandUint32(min, max uint32) uint32
- func Recover(cb ...RecoveryCallback)
- func RightPad(s, pad string, n int) string
- func RightPadBytes(b, pad []byte, n int) []byte
- func RunPath() string
- func S2B(s string) []byte
- func SafeGo(fn func(), cb ...RecoveryCallback)
- func SliceBigFilter(a []int, f func(v int) bool) []int
- func SliceDeleteElem(i int, s []any) ([]any, error)
- func SliceIntDeduplication(a []int) []int
- func SliceIntJoin(s []int, sep string) string
- func SliceReverse(s []any)
- func SliceShuffle(s []any)
- func SliceSmallFilter(a []int, f func(v int) bool) []int
- func SliceToInt(ss []string) (ii []int)
- func SubInLocation(ts time.Time) float64
- func WaitSignal(sig ...os.Signal) os.Signal
- type RecoveryCallback
Constants ¶
This section is empty.
Variables ¶
var ( // Rand goroutine-safe, use Rand.xxx instead of rand.xxx Rand = NewRand() Seed = FastRand() )
var (
StackTraceBufferSize = 4 << 10
)
Functions ¶
func B64UrlEncode ¶
B64UrlEncode Base64 解码, 安全 URL, 替换: "+/" 为 "-_"
func CSTLayoutString ¶
func CSTLayoutString() string
CSTLayoutString 格式化时间 返回 "2006-01-02 15:04:05" 格式的时间
func CSTLayoutStringToUnix ¶
CSTLayoutStringToUnix 返回 unix 时间戳 2020-01-24 21:11:11 => 1579871471
func CallPath ¶
func CallPath() string
CallPath 运行时路径, 编译目录 假如: mklink E:\tmp\linkapp.exe D:\Fufu\Test\abc\app.exe 执行: E:\tmp\linkapp.exe CallPath: E:\Go\src\github.com\fufuok\utils\tmp\osext
func Executable ¶
Executable 当前执行程序绝对路径 true 时返回解析符号链接后的绝对路径 Excutable: E:\tmp\linkapp.exe Excutable(true): D:\Fufu\Test\abc\app.exe
func ExecutableDir ¶
ExecutableDir 当前执行程序所在目录 true 时返回解析符号链接后的目录 ExcutableDir: E:\tmp ExcutableDir(true): D:\Fufu\Test\abc
func ExtractHostPort ¶
ExtractHostPort from address
func FastIntn ¶
FastIntn this is similar to rand.Intn, but faster. A non-negative pseudo-random number in the half-open interval [0,n). Return 0 if n <= 0.
func FastRandn ¶
FastRandn 等同于 FastRand() % n, 但更快 See https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/
func GMTLayoutString ¶
func GMTLayoutString() string
GMTLayoutString 格式化时间 返回 "Mon, 02 Jan 2006 15:04:05 GMT" 格式的时间
func InterfaceAddrs ¶
InterfaceAddrs 获取所有带 IP 的接口和对应的所有 IP 排除本地链路地址和环回地址
func MapBuildQuery ¶ added in v0.0.10
MapBuildQuery map => url query
func ParseCSTInLocation ¶
ParseCSTInLocation 格式化时间
func ParseGMTInLocation ¶
ParseGMTInLocation 格式化时间
func RandString ¶
RandString a random string, which may contain uppercase letters, lowercase letters and numbers. Ref: stackoverflow.icza
func SliceBigFilter ¶
SliceBigFilter 过滤切片元素 适合大切片
func SliceDeleteElem ¶
SliceDeleteElem 索引删除 slice 元素
func SliceIntDeduplication ¶
SliceIntDeduplication 去除重复的元素
func SliceSmallFilter ¶
SliceSmallFilter 过滤切片元素 适合小切片
Types ¶
type RecoveryCallback ¶
RecoveryCallback 自定义恢复信息回调