gotool

package module
v0.0.34 Latest Latest
Warning

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

Go to latest
Published: May 26, 2023 License: MIT Imports: 24 Imported by: 0

README

go-tool

Install

go get -u -v github.com/adimax2953/go-tool

File Archetecture

argtool
  • 參數檢查
bfttool
  • encrypt
    • 加解密相關
  • geo_ip
    • ip檢查
googledrivertool
  • google drive 相關功能
httptool
  • fasthttp為基底做的api client
iotool
  • 檔案操作相關
jsontool
  • 以 github.com/json-iterator/go 開發的json 加解密工具
kafkatool
  • kafka相關開發工具
  • docker-compose
    • 放docker-compose.yml
nsqtool
  • nsq相關開發工具
  • docker-compose
    • 放docker-compose.yml
rmqtool
  • rocketmq相關開發工具
  • docker-compose
    • 放docker-compose.yml
randtool
  • 基於梅森旋轉鏈(github.com/seehuhn/mt19937)開發的rng工具
Dependency
  • testify

      go get -u -v github.com/stretchr/testify
    
  • log-tool

      go get -u -v github.com/adimax2953/log-tool
    
  • rocketmq-client-go

      go get -u -v github.com/apache/rocketmq-client-go/v2
    
  • json-iterator

      go get -u -v github.com/json-iterator/go
    

Documentation

Index

Constants

This section is empty.

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 DataConvert added in v0.0.33

func DataConvert(from interface{}, dst interface{}) error

DataConvert - 資料轉換

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 GetStringEnd

func GetStringEnd(str string) string

GetStringEnd - 取得字串最後一碼字

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 InterfaceToString added in v0.0.33

func InterfaceToString(val interface{}) (res string)

InterfaceToString - Interface轉字串

func MD5Encryption added in v0.0.15

func MD5Encryption(str string) string

MD5

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 ParseStrToArrayInt32 added in v0.0.33

func ParseStrToArrayInt32(target string, sep string) []int32

ParseStrToArrayInt32 - ex: 123,555 -> [123,555]

func ParseStrToArrayStr added in v0.0.33

func ParseStrToArrayStr(target string, sep string) []string

ParseStrToArrayStr - ex: "嘎抓","打妹" -> ["嘎抓","打妹"]

func Percent added in v0.0.33

func Percent(value1, value2 int64) string

Percent - 取得 百分比

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 SliceMaxFloat64

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

func SliceMinFloat64

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

func StrToInt added in v0.0.33

func StrToInt(str string) int

StrToInt - 字串轉 Int

func StrToInt32 added in v0.0.33

func StrToInt32(str string) (int32, error)

StrToInt32 - 字串轉 Int32

func StrToInt64 added in v0.0.33

func StrToInt64(str string) int64

StrToInt64 - 字串轉 Int64

func TenMinutesTask added in v0.0.4

func TenMinutesTask()

TenMinutesTask - 每日排程

Types

type Aes added in v0.0.15

type Aes struct {
	BlockSize int
	Key       string
	Iv        string
}

func (*Aes) Decode added in v0.0.15

func (a *Aes) Decode(data string) (string, error)

開始解密

func (*Aes) Encode added in v0.0.15

func (a *Aes) Encode(data string) (string, error)

開始加密

func (*Aes) PKCS7Padding added in v0.0.15

func (a *Aes) PKCS7Padding(data []byte) []byte

func (*Aes) PKCS7UnPadding added in v0.0.15

func (a *Aes) PKCS7UnPadding(data []byte) []byte

type Decimal added in v0.0.34

type Decimal struct {
	Value   interface{}
	Decimal decimal.Decimal
	Error   error
}

func (*Decimal) DecimalInt64DivToString added in v0.0.34

func (d *Decimal) DecimalInt64DivToString(value int64, fixed int32) (string, error)

DecimalInt64DivToString 回傳含指定小數位數的浮點數字串 after the decimal point.

Example:

fixed(2) // output: "0.00"
fixed(0) // output: "0"
fixed(0) // output: "5"
fixed(1) // output: "5.4"
fixed(2) // output: "5.45"
fixed(3) // output: "5.450"
fixed(-1) // output: "540"

func (*Decimal) DecimalMulToInt64 added in v0.0.34

func (d *Decimal) DecimalMulToInt64(value int64) (int64, error)

DecimalMulToInt64

func (*Decimal) InterfaceToDecimal added in v0.0.34

func (d *Decimal) InterfaceToDecimal() *Decimal

InterfaceToDecimal - Interface轉Decimal

type Negative_Number added in v0.0.17

type Negative_Number interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64
}

type NonNegative_Integer added in v0.0.17

type NonNegative_Integer interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type NonNegative_Number added in v0.0.17

type NonNegative_Number interface {
	~float32 | ~float64 | ~complex64 | ~complex128
}

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 Timer added in v0.0.25

type Timer struct {
	Actor sync.Map
	// contains filtered or unexported fields
}

Timer -

func (*Timer) AddFunc added in v0.0.25

func (m *Timer) AddFunc(name string, act func()) bool

AddFunc -

func (*Timer) RemoveFunc added in v0.0.25

func (m *Timer) RemoveFunc(name string)

RemoveFunc -

func (*Timer) Start added in v0.0.25

func (m *Timer) Start(d time.Duration)

Start -

func (*Timer) Stop added in v0.0.25

func (m *Timer) Stop()

Stop -

Jump to

Keyboard shortcuts

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