gotool

package module
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DateLayout     = "2006-01-02"
	TimeLayout     = "15:04:05"
	DateTimeLayout = "2006-01-02 15:04:05"
)

Variables

This section is empty.

Functions

func AbsInt32

func AbsInt32(n int32) int32

AbsInt32 -整數轉正

func Base62Increment added in v0.0.5

func Base62Increment(s string) string

遞增字符串ByBase62

func BubbleSort

func BubbleSort(list []int32) []int32

氣泡排序Sli(小到大)

func Compress added in v0.0.11

func Compress(s string) string

func DateFromNow

func DateFromNow() string

現在時間 格式為"2006-01-02"

func DateFromTimeStamp

func DateFromTimeStamp(timestamp int64) string

透過time.Now().Unix()出來的秒數轉為 "2006-01-02"

func DateTimeFromNow added in v0.0.6

func DateTimeFromNow() string

現在時間 格式為"2006-01-02 15:04:05"

func DateTimeFromTimeStamp added in v0.0.6

func DateTimeFromTimeStamp(timestamp int64) (string, string)

透過time.Now().Unix()出來的秒數轉為 "2006-01-02" "15:04:05"

func Decode62To10 added in v0.0.10

func Decode62To10(str string) int64

Decode62To10 - 62進制轉 10

func Encode10To62 added in v0.0.10

func Encode10To62(num int64) string

Encode10To62 - 10進制轉 62

func FloatToStr

func FloatToStr(f float64) string

Float轉Str - 浮點數轉換成字符串

func Get

func Get(url string) (response string)

发送GET请求 url:请求地址 response:请求返回的内容

func GetStringEnd

func GetStringEnd(str string) string

GetStringEnd -取得字串最後一碼字

func GetWeek added in v0.0.7

func GetWeek() (y, w int)

透過time.Now()出來的年份跟週數

func Int32Sum

func Int32Sum(int32arr []int32) int32

int32 slice 加總

func Int32SumParallel

func Int32SumParallel(numbers []int32) int32

func Int32ToStr

func Int32ToStr(n int32) string

Int32轉str - 將整形轉換成字符串

func Int64ToStr

func Int64ToStr(n int64) string

Int64轉str - 將整形轉換成字符串

func IntArrEq

func IntArrEq(a, b []int) bool

IntArrEq - 兩個Int arr比較是否相等

func IntToStr

func IntToStr(n int) string

Int轉str - 將整形轉換成字符串

func Max added in v0.0.13

func Max(vals ...int64) int64

func MaxNum added in v0.0.13

func MaxNum(arr []int64) (max int64, maxIndex int)

func Min added in v0.0.13

func Min(vals ...int64) int64

func MinNum added in v0.0.13

func MinNum(arr []int64) (min int64, minIndex int)

func Post

func Post(url string, data interface{}, contentType string) (content string)

发送POST请求 url:请求地址, data:POST请求提交的数据,contentType:请求体格式, 如:application/json content:请求放回的内容

func QuickSort

func QuickSort(list []int32, left int32, right int32)

region 快速排序

func RecoverPanic added in v0.0.3

func RecoverPanic()

func RemoveSliInt

func RemoveSliInt(slice []int32, elem int32) []int32

RemoveSliInt - 移除slice中的某個元素(int)

func RemoveSliStr

func RemoveSliStr(slice []string, elem string) []string

RemoveSliStr - 移除slice中的某個元素(str)

func Removeduplicate

func Removeduplicate(a interface{}) (ret []interface{})

func RemoveduplicateMap

func RemoveduplicateMap(DataArr []int32) []int32

去除重複資料 壓測效能優化

func RoundingFour

func RoundingFour(value float64) float64

RoundingFour - 四捨五入取小數四位

func RoundingSeven

func RoundingSeven(value float64) float64

RoundingSeven - 四捨五入取小數七位(後端統一)

func RoundingTwo

func RoundingTwo(value float64) float64

RoundingTwo - 四捨五入取小數兩位

func SearchSliFlt

func SearchSliFlt(slice []float64, elem float64) bool

SearchSliFlt - 檢查silce中有沒有此元素(float64)

func SearchSliInt

func SearchSliInt(slice []int, elem int) bool

SearchSliInt - 檢查silce中有沒有此元素(int)

func SearchSliInt32

func SearchSliInt32(slice []int32, elem int32) bool

SearchSliInt32 - 檢查silce中有沒有此元素(int32)

func SearchSliInt64

func SearchSliInt64(slice []int64, elem int64) bool

SearchSliInt64 - 檢查silce中有沒有此元素(int64)

func SearchSliStr

func SearchSliStr(slice []string, elem string) bool

SearchSliStr - 檢查silce中有沒有此元素(str)

func SendGameEventToTG added in v0.0.12

func SendGameEventToTG(TgbotChatID int, TgbotToken, game, env, reson string)

func SendTextToTelegramChat

func SendTextToTelegramChat(chatId int, text string, Token string) (string, error)

SendTextToTelegramChat -發送訊息到TelegramChat

func SendToTG

func SendToTG(TgbotChatID int, TgbotToken, env, reson string)

func SliceMaxFloat64

func SliceMaxFloat64(l []float64) (max float64)

func SliceMinFloat64

func SliceMinFloat64(l []float64) (min float64)

func Str2Int

func Str2Int(str string) int

Str2Int - 字串轉Int

func Str2int32

func Str2int32(str string) (int32, error)

Str2int32 - 字串轉 Int32

func Str2int64

func Str2int64(str string) int64

Str2int64 - 字串轉Int64

func TenMinutesTask added in v0.0.4

func TenMinutesTask()

TenMinutesTask - 每日排程

func TimeFromNow added in v0.0.6

func TimeFromNow() string

現在時間 格式為"15:04:05"

func TimeFromTimeStamp added in v0.0.6

func TimeFromTimeStamp(timestamp int64) string

透過time.Now().Unix()出來的秒數轉為 "15:04:05"

func TimeNowStr

func TimeNowStr() string

TimeNowStr 輸出格式為 2019/11/4 20:15:26

func TimeStamptoDateTime added in v0.0.6

func TimeStamptoDateTime(timestamp int64) string
轉化成"2006-01-02 15:04:05"的時間模版

輸入為time.Now().Unix()

func TimestrToTimestamp

func TimestrToTimestamp(time_str string, flag int) int64

日期格式轉時間戳

Types

type Queue

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

func CreateQueue

func CreateQueue() *Queue

func (*Queue) Back

func (q *Queue) Back() interface{}

取得尾元素

func (*Queue) Begin

func (q *Queue) Begin() *QueueNode

取得首節點, 外部遍歷需要

func (*Queue) Clear

func (q *Queue) Clear()

func (*Queue) End

func (q *Queue) End() *QueueNode

取得尾節點, 外部遍歷需要

func (*Queue) Front

func (q *Queue) Front() interface{}

取得首元素

func (*Queue) Init

func (q *Queue) Init()

func (*Queue) PopFront

func (q *Queue) PopFront() interface{}

彈出首元素

func (*Queue) PushBack

func (q *Queue) PushBack(elem interface{})

func (*Queue) Range

func (q *Queue) Range(callback func(v interface{}) bool)

遍歷鍊錶

func (*Queue) Remove

func (q *Queue) Remove(ele interface{}) bool

傳入一個元素, 如果鍊錶中有, 即移除

func (*Queue) SetCapactiy

func (q *Queue) SetCapactiy(c uint32) uint32

一開始就要設置, 如果已經有了內容, 則只能設置為和當前容量一樣大小

func (*Queue) ShowSelf

func (q *Queue) ShowSelf()

func (*Queue) Size

func (q *Queue) Size() uint32

type QueueNode

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

先定義隊例節點

func (*QueueNode) Next

func (qn *QueueNode) Next() *QueueNode

func (*QueueNode) Value

func (qn *QueueNode) Value() interface{}

type Ticker

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

Ticker 定義一個Ticker,用於時間控制

type TickerManager

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

TickerManager 封裝一個tick的管理類,避免每次都要寫一大堆

func GetTickManager

func GetTickManager() *TickerManager

GetTickManager 得到tickmanage

func (*TickerManager) ClearTicker

func (tm *TickerManager) ClearTicker(id uint64)

ClearTicker 清除tick, 停止tick

func (*TickerManager) DelayExec

func (tm *TickerManager) DelayExec(callback func(), d time.Duration) uint64

DelayExec 延遲執行函數

func (*TickerManager) Init

func (tm *TickerManager) Init()

Init 初始化tickermanager, 就是設置起始id

type WorkPool added in v0.0.4

type WorkPool struct {
	Pool *ants.Pool
}

func NewWorkPool added in v0.0.4

func NewWorkPool(poolsize int) *WorkPool

NewWorkPool - 建立一個工作池 poolsize:要有多少線呈 return WorkPool

func (*WorkPool) ChangePoolSize added in v0.0.8

func (wp *WorkPool) ChangePoolSize(poolsize int)

ChangePoolSize - 修改一個工作池 poolsize:要改多少線呈

func (*WorkPool) NewWorkPoolWithFunc added in v0.0.4

func (wp *WorkPool) NewWorkPoolWithFunc(poolsize int, poolfunc func(interface{})) (*ants.PoolWithFunc, error)

NewWorkPool - 建立WorkPool poolsize:要有多少線呈 return PoolWithFunc

func (*WorkPool) Reboot added in v0.0.4

func (wp *WorkPool) Reboot()

Reboot - 重啟WorkPool

func (*WorkPool) Release added in v0.0.4

func (wp *WorkPool) Release()

Release - 釋放WorkPool

func (*WorkPool) SubmitTask added in v0.0.4

func (wp *WorkPool) SubmitTask(task func()) error

SubmitTask - 提交一個工作到WorkPool task : 要做事的funtion

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳