kameria

package module
v0.0.0-...-861ca8c Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: MIT Imports: 11 Imported by: 0

README

kameria

前途一片黑暗, 不知道未来还能不能养得起房东, 心好累

阿库娅大人说: "今天能养得起房东就今天养吧,反正明天也不一定养得起。就算养不起了,那也是世界的错!"

我老婆说: "我讨厌的事有三件『办不到、好累、好麻烦』这三句话非常不好, 会抹杀人类所拥有的无限可能。"

随意堆砌, 企图发酵

胡闹

func StructTagMap(tag string, model interface{}) (map[string]interface{}, error)

映射struct tag对应元素的指针地址

后面应该会基于这个功能写一些方便操作

func IPv4StringToInt(ipStr string) (int64, error)

IPv4三点数表示法转10进制值地址

func IPv4IntToString(ipInt int64) (string, error)

10进制地址转IPv4三点数表示法

func Limit4Int(min, mid, max int) int
func Limit4Int64(min, mid, max int64) int64
func Limit4Float32(min, mid, max float32) float32
func Limit4Float64(min, mid, max float64) float64

范围取值

func uintptrAddress(v interface{}) (uintptr, error)

获取元素指针地址值, 暂不开放

func Href2Url(href, baseURL string) string

href转完整的url

func Float2String(i interface{}) string

浮点数转字符串, 格式为'f'

[]interface{}转化

kameria.SliceToInterfaces(slice interface{}) []interface{}

失败时返回nil

Unique

切片去重

kameria.Unique.Ints(x []int) []int
kameria.Unique.Int64s(x []int64) []int64
kameria.Unique.Strings(x []string) []string

其他

日常定时器

任务队列

k-math

algorithm

[]byte 转 fs.FS

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Math = math{}

Math for call kmath func simply without type

View Source
var Unique = unique{}

Unique support []string, []int, []int64

Functions

func Float2String

func Float2String(i interface{}) string

Float2String float to 'f' string

func Href2Url

func Href2Url(href, baseURL string) string

Href2Url href to url

func IPv4IntToString

func IPv4IntToString(ipInt int64) (string, error)

IPv4IntToString 2130706433 -> "127.0.0.1"

func IPv4StringToInt

func IPv4StringToInt(ipStr string) (int64, error)

IPv4StringToInt "127.0.0.1" -> 2130706433

func Limit4Float32

func Limit4Float32(min, mid, max float32) float32

Limit4Float32 return mid ∈ [min, max]

func Limit4Float64

func Limit4Float64(min, mid, max float64) float64

Limit4Float64 return mid ∈ [min, max]

func Limit4Int

func Limit4Int(min, mid, max int) int

Limit4Int return mid ∈ [min, max]

func Limit4Int64

func Limit4Int64(min, mid, max int64) int64

Limit4Int64 return mid ∈ [min, max]

func SliceToInterfaces

func SliceToInterfaces(slice interface{}) []interface{}

SliceToInterfaces slice -> []interface{}

func StructTagMap

func StructTagMap(tag string, model interface{}) (map[string]interface{}, error)

StructTagMap map[tag key] value address

Types

type DayTicker

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

DayTicker once every day

func NewDayTicker

func NewDayTicker(hr, min, sec int) *DayTicker

NewDayTicker (hour, minute, second)

func (*DayTicker) Hour

func (slf *DayTicker) Hour(hr ...int) int

Hour [0, 23]

Get when hr is empty
Set when hr has value

func (*DayTicker) Minute

func (slf *DayTicker) Minute(min ...int) int

Minute [0, 59]

Get when min is empty
Set when min has value

func (*DayTicker) Next

func (slf *DayTicker) Next() time.Time

Next to next time ±1s

func (*DayTicker) Second

func (slf *DayTicker) Second(sec ...int) int

Second [0, 59]

Get when sec is empty
Set when sec has value

type OnceMutex

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

OnceMutex sync.Once + Reset

func (*OnceMutex) Do

func (slf *OnceMutex) Do(f func())

Do once.Do

func (*OnceMutex) Reset

func (slf *OnceMutex) Reset(sync ...bool)

Reset reset once

type OperationQueue

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

OperationQueue task queue

func (*OperationQueue) Add

func (slf *OperationQueue) Add(operation func())

Add add operation

func (*OperationQueue) MaxConcurrentOperationCount

func (slf *OperationQueue) MaxConcurrentOperationCount(cnt ...int) int

MaxConcurrentOperationCount cnt >= 1

Get when cnt is empty
Set when cnt has value

func (*OperationQueue) Wait

func (slf *OperationQueue) Wait()

Wait blocks until the WaitGroup counter is zero.

Directories

Path Synopsis
container
internal

Jump to

Keyboard shortcuts

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