Documentation ¶
Index ¶
- Constants
- func BuildFormat(info HelpInfo) string
- func CheckIfError(err error)
- func CopyObj[T any, R any](src T) *R
- func CopyStream(src io.ReadCloser) ([]byte, io.ReadCloser)
- func GetInternalIP() string
- func Home() (string, error)
- func IsFileExist(path string) bool
- func IsNil(vo interface{}) bool
- func OpenBrowser(url string) error
- func PostJson(url string, value interface{}) ([]byte, error)
- func PostJsons(url string, value []byte) ([]byte, error)
- func PrintParams(format string, flagColor Color, params []ParamVO)
- func PrintTitle(command string, helpInfo HelpInfo)
- func PrintWithColorful()
- func RandomAlNum(length int) string
- func RandomAlNumValid(length int) string
- func RandomAlpha(length int) string
- func ReadCsvLines(filename string) [][]string
- func ReadLines[T any](filename string, filterFunc func(string) bool, mapFunc func(string) T) []T
- func ReadLinesNoFilter[T any](filename string, mapFunc func(string) T) []T
- func ReadStrLines(filename string, filterFunc func(string) bool) []string
- func ReadStrLinesNoFilter(filename string) []string
- func ReadTsvLines(filename string) [][]string
- func ToJSONBuffer(val any) *bytes.Buffer
- func Unpack(req *http.Request, ptr interface{}) error
- type ArrayFlags
- type BufferWriter
- type Cache
- type Color
- type DoublyLinkedList
- func (list *DoublyLinkedList[T]) Add(data T)
- func (list *DoublyLinkedList[T]) AddToHead(data T)
- func (list *DoublyLinkedList[T]) Clear()
- func (list *DoublyLinkedList[T]) Find(data T) *DoublyLinkedNode[T]
- func (list *DoublyLinkedList[T]) IsEmpty() bool
- func (list *DoublyLinkedList[T]) PrintList()
- func (list *DoublyLinkedList[T]) PrintListWithDetail(needDetail bool)
- func (list *DoublyLinkedList[T]) Remove(data T)
- func (list *DoublyLinkedList[T]) RemoveNode(node *DoublyLinkedNode[T])
- func (list *DoublyLinkedList[T]) RemoveTail()
- func (list *DoublyLinkedList[T]) ReverseBySingle() *DoublyLinkedList[T]
- type DoublyLinkedNode
- type Entry
- type Float
- type HelpInfo
- type Integer
- type LRUCache
- type Map
- type MapEntry
- type Maps
- type MapsEntry
- type Number
- type Ordered
- type PageVO
- type ParamInfo
- type ParamVO
- type PeriodRateLimiter
- type Queue
- type ResultVO
- type Set
- func (s *Set[T]) Add(val ...T)
- func (s *Set[T]) Adds(set *Set[T])
- func (s *Set[T]) Clear()
- func (s *Set[T]) Contains(val T) bool
- func (s *Set[T]) Difference(set *Set[T]) *Set[T]
- func (s *Set[T]) Intersect(set *Set[T]) *Set[T]
- func (s *Set[T]) IsEmpty() bool
- func (s *Set[T]) Join(str string) string
- func (s *Set[T]) Len() int
- func (s *Set[T]) Loop(action func(T))
- func (s *Set[T]) Remove(val T)
- func (s *Set[T]) Supplementary(set *Set[T]) *Set[T]
- func (s *Set[T]) Union(set *Set[T]) *Set[T]
- type Signed
- type StopWatch
- type TaskInfo
- type Unsigned
- type Value
Constants ¶
View Source
const ( YYYY = "2006" YYYY_MM = "2006-01" YYYY_MM_DD = "2006-01-02" YYYY_MM_DD_HH = "2006-01-02 15" YYYY_MM_DD_HH_MM = "2006-01-02 15:04" YYYY_MM_DD_HH_MM_SS = "2006-01-02 15:04:05" YYYY_MM_DD_HH_MM_SS_MS = "2006-01-02 15:04:05.000" HH_MM_SS = "15:04:05" HH_MM_SS_MS = "15:04:05.000" )
View Source
const ( SUCCESS = 0 FAILED = 1 )
Variables ¶
This section is empty.
Functions ¶
func CopyStream ¶ added in v1.1.0
func CopyStream(src io.ReadCloser) ([]byte, io.ReadCloser)
func GetInternalIP ¶ added in v1.0.1
func GetInternalIP() string
func OpenBrowser ¶ added in v1.0.1
func PrintParams ¶ added in v1.0.1
PrintParams
func RandomAlNum ¶ added in v1.1.1
func RandomAlNumValid ¶ added in v1.1.1
RandomAlNumValid 生成非数字开头的字符串,数据库等地方使用
func RandomAlpha ¶ added in v1.1.1
func ReadCsvLines ¶
func ReadLinesNoFilter ¶
ReadLinesNoFilter only map
func ReadStrLinesNoFilter ¶
func ReadTsvLines ¶
Types ¶
type ArrayFlags ¶ added in v1.0.1
type ArrayFlags []string
func (*ArrayFlags) Set ¶ added in v1.0.1
func (i *ArrayFlags) Set(value string) error
Set 方法是flag.Value接口, 设置flag Value的方法. 通过多个flag指定的值, 所以我们追加到最终的数组上.
type BufferWriter ¶
type BufferWriter struct {
// contains filtered or unexported fields
}
func NewWriterIgnoreError ¶
func NewWriterIgnoreError(filePath string, truncate bool) *BufferWriter
func (*BufferWriter) Close ¶
func (w *BufferWriter) Close()
func (*BufferWriter) WriteString ¶
func (w *BufferWriter) WriteString(val string) (nn int, err error)
type Color ¶ added in v1.0.1
type Color string
const ( Red Color = "\033[0;31m" Green Color = "\033[0;32m" Yellow Color = "\033[0;33m" Blue Color = "\033[0;34m" Purple Color = "\033[0;35m" Cyan Color = "\033[0;36m" White Color = "\033[0;37m" LightRed Color = "\033[0;91m" LightGreen Color = "\033[0;92m" LightYellow Color = "\033[0;93m" LightBlue Color = "\033[0;94m" LightPurple Color = "\033[0;95m" LightCyan Color = "\033[0;96m" LightWhite Color = "\033[0;97m" End Color = "\033[0m" )
func (Color) PrintNoEnd ¶ added in v1.0.1
Print content with color no end
type DoublyLinkedList ¶ added in v1.0.4
type DoublyLinkedList[T any] struct { // contains filtered or unexported fields }
func NewDoublyLinkedList ¶ added in v1.0.4
func NewDoublyLinkedList[T any](head, tail *DoublyLinkedNode[T]) *DoublyLinkedList[T]
func NewEmptyDoublyLinkedList ¶ added in v1.0.4
func NewEmptyDoublyLinkedList[T any]() *DoublyLinkedList[T]
func (*DoublyLinkedList[T]) Add ¶ added in v1.0.4
func (list *DoublyLinkedList[T]) Add(data T)
Add to tail
func (*DoublyLinkedList[T]) AddToHead ¶ added in v1.0.4
func (list *DoublyLinkedList[T]) AddToHead(data T)
func (*DoublyLinkedList[T]) Clear ¶ added in v1.0.4
func (list *DoublyLinkedList[T]) Clear()
func (*DoublyLinkedList[T]) Find ¶ added in v1.0.4
func (list *DoublyLinkedList[T]) Find(data T) *DoublyLinkedNode[T]
func (*DoublyLinkedList[T]) IsEmpty ¶ added in v1.0.4
func (list *DoublyLinkedList[T]) IsEmpty() bool
func (*DoublyLinkedList[T]) PrintList ¶ added in v1.0.4
func (list *DoublyLinkedList[T]) PrintList()
func (*DoublyLinkedList[T]) PrintListWithDetail ¶ added in v1.0.4
func (list *DoublyLinkedList[T]) PrintListWithDetail(needDetail bool)
func (*DoublyLinkedList[T]) Remove ¶ added in v1.0.4
func (list *DoublyLinkedList[T]) Remove(data T)
func (*DoublyLinkedList[T]) RemoveNode ¶ added in v1.0.4
func (list *DoublyLinkedList[T]) RemoveNode(node *DoublyLinkedNode[T])
func (*DoublyLinkedList[T]) RemoveTail ¶ added in v1.0.4
func (list *DoublyLinkedList[T]) RemoveTail()
func (*DoublyLinkedList[T]) ReverseBySingle ¶ added in v1.0.4
func (list *DoublyLinkedList[T]) ReverseBySingle() *DoublyLinkedList[T]
单链表反转 三个指针前进
type DoublyLinkedNode ¶ added in v1.0.4
type DoublyLinkedNode[T any] struct { // contains filtered or unexported fields }
func NewDoublyLinkedNode ¶ added in v1.0.4
func NewDoublyLinkedNode[T any](pre, next *DoublyLinkedNode[T], data T) *DoublyLinkedNode[T]
func NewEmptyDoublyLinkedNode ¶ added in v1.0.4
func NewEmptyDoublyLinkedNode[T any](data T) *DoublyLinkedNode[T]
type HelpInfo ¶ added in v1.0.1
type LRUCache ¶ added in v1.0.4
type LRUCache[T any] struct { // contains filtered or unexported fields }
func NewLRUCache ¶ added in v1.0.4
type Map ¶ added in v1.0.8
type Map[K, V comparable] struct { // contains filtered or unexported fields }
func NewMap ¶ added in v1.0.8
func NewMap[K, V comparable](k ...MapEntry[K, V]) *Map[K, V]
type MapEntry ¶ added in v1.0.8
type MapEntry[K, V comparable] struct { Key K Val V }
func NewSortMap ¶ added in v1.1.9
func NewSortMap[K comparable, V constraints.Ordered](origin map[K]V) []MapEntry[K, V]
type Maps ¶ added in v1.0.8
type Maps[K, V comparable] struct { // contains filtered or unexported fields }
func NewMaps ¶ added in v1.0.8
func NewMaps[K, V comparable](k ...MapsEntry[K, V]) *Maps[K, V]
type MapsEntry ¶ added in v1.0.8
type MapsEntry[K, V comparable] struct { Key K Val []V }
type PeriodRateLimiter ¶ added in v1.0.6
type PeriodRateLimiter struct {
// contains filtered or unexported fields
}
func NewLimiter ¶ added in v1.0.6
func NewLimiter(slideWindow time.Duration, maxCount int) *PeriodRateLimiter
func NewMinuteLimiter ¶ added in v1.0.6
func NewMinuteLimiter(maxCount int) *PeriodRateLimiter
NewMinuteLimiter 限流: maxCount/min
func NewSecondLimiter ¶ added in v1.0.6
func NewSecondLimiter(maxCount int) *PeriodRateLimiter
NewSecondLimiter 限流:maxCount/s
func (*PeriodRateLimiter) Acquire ¶ added in v1.0.7
func (l *PeriodRateLimiter) Acquire() bool
func (*PeriodRateLimiter) CalculateCount ¶ added in v1.0.7
func (l *PeriodRateLimiter) CalculateCount()
calculateCount 移除 滑动窗口外的元素
简单压测可发现 队列重整理耗时很小
func (*PeriodRateLimiter) QueueState ¶ added in v1.0.7
func (l *PeriodRateLimiter) QueueState() int
type Queue ¶ added in v1.0.6
type Queue[T any] struct { // contains filtered or unexported fields }
type ResultVO ¶ added in v1.0.2
func FailedWithMsg ¶ added in v1.0.2
func SuccessWith ¶ added in v1.0.2
func SuccessWith[T any](data T) ResultVO[T]
type Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
func NewSet ¶
func NewSet[T comparable](s ...T) *Set[T]
func (*Set[T]) Difference ¶
Difference 差集: 在当前集合 但是 不在参数集合内
func (*Set[T]) Supplementary ¶
Supplementary 补集 余集
type StopWatch ¶ added in v1.0.9
type StopWatch struct {
// contains filtered or unexported fields
}
StopWatch inspire by spring stopwatch
func NewStopWatch ¶ added in v1.0.9
func NewStopWatch() *StopWatch
func NewStopWatchWithName ¶ added in v1.0.9
func (StopWatch) GetTaskCount ¶ added in v1.0.9
func (StopWatch) GetTotalDuration ¶ added in v1.0.9
func (StopWatch) PrettyPrint ¶ added in v1.0.9
Source Files ¶
Click to show internal directories.
Click to hide internal directories.