Documentation ¶
Overview ¶
Package tools Copyright 2023 marcello<volibearw@gmail.com>. All rights reserved.
Package tools Copyright 2023 marcello<volibearw@gmail.com>. All rights reserved.
Package tools Copyright 2016-2023 chad.wang<chad.wang@icloudsky.com>. All rights reserved.
Package tools Copyright 2023 marcello<volibearw@gmail.com>. All rights reserved.
Package tools Copyright 2023 marcello<volibearw@gmail.com>. All rights reserved.
Package tools Copyright 2023 marcello<volibearw@gmail.com>. All rights reserved.
Package tools Copyright 2023 marcello<volibearw@gmail.com>. All rights reserved.
Package tools Copyright 2023 marcello<volibearw@gmail.com>. All rights reserved.
Package tools Copyright 2023 marcello<volibearw@gmail.com>. All rights reserved.
Package tools Copyright 2023 marcello<volibearw@gmail.com>. All rights reserved.
Package tools Copyright 2016-2023 volibear<volibearw@gmail.com>. All rights reserved.
Package tools Copyright 2023 marcello<volibearw@gmail.com>. All rights reserved.
Package tools Copyright 2016-2023 chad.wang<chad.wang@icloudsky.com>. All rights reserved.
Index ¶
- Constants
- func Close(f io.Closer)
- func FormatTime[T constraints.Float | constraints.Integer](sec T, nsec T) string
- func GetCurrentDirectory() string
- func IsNumber(s string) bool
- func JSONMarshalByte(v interface{}) []byte
- func JSONMarshalString(v interface{}) string
- func Md5(s string) string
- func Md5File(filePath string) (string, error)
- func PathExists(path string) (bool, error)
- func RandomString(length uint, charType randomType) (s string)
- func RemoveSameFromStringSlice(slice []string) []string
- func ReverseByte(s []byte) []byte
- func SliceRemove[T comparable](remove []T, s []T) []T
- func SliceTrimSame[T comparable](s []T) []T
- func XMLMarshalByte(v interface{}) []byte
- func XMLMarshalString(v interface{}) string
- type PaginationData
- type TSMap
Constants ¶
const ( // RandomLowercase lowercase RandomLowercase randomType = 2 << iota // RandomMajuscule majuscule RandomMajuscule // RandomDigital digital RandomDigital // RandomSymbol symbol RandomSymbol // RandomAll all RandomAll = RandomLowercase | RandomMajuscule | RandomDigital | RandomSymbol )
const IsDarwin = false
const IsLinux = true
const IsWindows = false
const TimeFormatString = "2006-01-02 15:04:05"
TimeFormatString time layout
Variables ¶
This section is empty.
Functions ¶
func FormatTime ¶
func FormatTime[T constraints.Float | constraints.Integer](sec T, nsec T) string
FormatTime format time use TimeFormatString layout
func GetCurrentDirectory ¶
func GetCurrentDirectory() string
GetCurrentDirectory return current execute file directory
func JSONMarshalByte ¶
func JSONMarshalByte(v interface{}) []byte
JSONMarshalByte ignore error, return JSON.Marshal []byte()
func JSONMarshalString ¶
func JSONMarshalString(v interface{}) string
JSONMarshalString ignore error,return JSON.Marshal string
func RandomString ¶
RandomString random a string
func RemoveSameFromStringSlice ¶
RemoveSameFromStringSlice remove []string same element Deprecated: use SliceTrimSame replace
func XMLMarshalByte ¶ added in v0.0.6
func XMLMarshalByte(v interface{}) []byte
XMLMarshalByte ignore error, return xml.Marshal []byte()
func XMLMarshalString ¶ added in v0.0.6
func XMLMarshalString(v interface{}) string
XMLMarshalString ignore error,return xml.Marshal string
Types ¶
type PaginationData ¶
type PaginationData struct { Total int64 // total record Page int64 // current page PageSize int64 // show size every page PageNums int64 // show digital numbers on page FirstPage int64 // first page LastPage int64 // last page PreviousPage int64 // previous page NextPage int64 // next page TotalPage int64 // total page Pages []int64 // pages }
PaginationData pagination data
func Pagination ¶
func Pagination(total, page, pageSize int64, pageNum int64) (pg *PaginationData)
Pagination calculate total record page current page pageSize show size every page pagesNum show digital numbers on page
type TSMap ¶ added in v0.0.7
type TSMap[K, T any] struct { // contains filtered or unexported fields }
TSMap thread safe map
func (*TSMap[K, T]) Load ¶ added in v0.0.7
Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.
func (*TSMap[K, T]) LoadAndDelete ¶ added in v0.0.7
LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present.
func (*TSMap[K, T]) LoadOrStore ¶ added in v0.0.7
LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored.
func (*TSMap[K, T]) Range ¶ added in v0.0.7
Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.
Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently (including by f), Range may reflect any mapping for that key from any point during the Range call. Range does not block other methods on the receiver; even f itself may call any method on m.
Range may be O(N) with the number of elements in the map even if f returns false after a constant number of calls.