util4go

package module
v1.0.26 Latest Latest
Warning

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

Go to latest
Published: May 12, 2022 License: Apache-2.0 Imports: 15 Imported by: 5

README

boot4go-util

a utility toolkit for golang

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RegExpPool = make(regExpPool)

Functions

func BinarySearch

func BinarySearch(a []string, v interface{}) int

func BuildFormatString

func BuildFormatString(format string, a ...any) string

func BuildString

func BuildString(a ...any) string

func BytesToInt added in v1.0.20

func BytesToInt[T int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](bytesArr []byte, data *T) T

BytesToInt 将以Big端存储的长为1/2字节的数转化成int类型的数

func BytesToIntEndian added in v1.0.20

func BytesToIntEndian[T int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](bytesArr []byte, data *T, endian Endian) T

func Collect added in v1.0.24

func Collect[T any, V any](source []T, fn func(one T) V) []V

func Copy added in v1.0.16

func Copy[T any](src *T) *T

func CopyArray added in v1.0.5

func CopyArray[T any](src []any, dest []T) []T

func ElmType

func ElmType(value reflect.Value) reflect.Type

func GetBool added in v1.0.25

func GetBool(s string) (bool, error)

func GetFloat added in v1.0.25

func GetFloat(s string) (float64, error)

func GetIPv4ByInterface added in v1.0.4

func GetIPv4ByInterface(name string) ([]string, error)

GetIPv4ByInterface return IPv4 address from a specific interface IPv4 addresses

func GetInt added in v1.0.25

func GetInt(s string) (int64, error)

func GetUint added in v1.0.25

func GetUint(s string) (uint64, error)

func GroupBy added in v1.0.24

func GroupBy[T any, K Keyable](source []T, fn func(one T) K) map[K][]T

func GuessIP added in v1.0.4

func GuessIP(remote string) *string

GuessIP 获取连接远程的本地ip

func IP added in v1.0.16

func IP(ip string) string

func InsertAt added in v1.0.19

func InsertAt[T any](list []T, idx int, t T) []T

func Int64ToStr

func Int64ToStr(i int64) string

Int64ToStr int64 to str

func IntToBytes added in v1.0.20

func IntToBytes[T int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](intNum T) []byte

IntToBytes 将int类型的数转化为字节并以Big端存储

func IntToBytesEndian added in v1.0.20

func IntToBytesEndian[T int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](intNum T, endian Endian) []byte

IntToBytesEndian 将int类型的数转化为字节并以Big端存储

func IsEmpty

func IsEmpty(str string) bool

func LeftPad

func LeftPad(str string, limit int, placeholder rune) string

func LocalIPv4s added in v1.0.4

func LocalIPv4s() ([]string, error)

LocalIPv4s 获取本地内网ip LocalIPs return all non-loopback IPv4 addresses

func MD5

func MD5(data string) string

func Map added in v1.0.24

func Map[T any, K Keyable](source []T, fn func(T) K) map[K]T

func MapStream added in v1.0.24

func MapStream[T any, K Keyable](source map[K]T, fn func(K, T))

func NewInstanceValue

func NewInstanceValue(t reflect.Type) reflect.Value

func ParseParameterName

func ParseParameterName(str string) []string

func ParseURL added in v1.0.22

func ParseURL(url string) (schema, host, query string, rtnErr error)

func RandRune added in v1.0.12

func RandRune() rune

func RandRune2 added in v1.0.12

func RandRune2(s, e rune) rune

func Reduce

func Reduce[T any, R any](source []T, fn func(one T) (R, bool)) []R

func RemoveAt added in v1.0.19

func RemoveAt[T any](list []T, idx int) []T

func ReplaceAt added in v1.0.19

func ReplaceAt[T any](list []T, idx int, t T) []T

func ReplaceIP added in v1.0.10

func ReplaceIP(address, ip string) string

ReplaceIP 获取连接远程的本地ip

func ReplaceParameterValue

func ReplaceParameterValue(str string, keyAndValue map[string]string) string

func ReplaceParameterWithKeyValue

func ReplaceParameterWithKeyValue(str string, keyAndValue map[string]string) string

func ReplacePort added in v1.0.17

func ReplacePort(address, port string) string

func Reverse added in v1.0.25

func Reverse[T any](source []T) []T

func RightPad added in v1.0.11

func RightPad(str string, limit int, placeholder rune) string

func SaltMd5

func SaltMd5(data, salt string) string

func SetUnExportFieldValue added in v1.0.21

func SetUnExportFieldValue[T any](obj *T, field string, data any) (rtnErr error)

func SplitHostPort added in v1.0.16

func SplitHostPort(address string) (host, port string, err error)

func Str2Bool

func Str2Bool(source string) (any, error)

func Str2Float32

func Str2Float32(source string) (any, error)

func Str2Float64

func Str2Float64(source string) (any, error)

func Str2Int

func Str2Int(source string) (any, error)

func Str2Int16

func Str2Int16(source string) (any, error)

func Str2Int32

func Str2Int32(source string) (any, error)

func Str2Int64

func Str2Int64(source string) (any, error)

func Str2Int8

func Str2Int8(source string) (any, error)

func Str2Object

func Str2Object(v string, k reflect.Kind) (any, error)

func Str2UInt64

func Str2UInt64(source string) (any, error)

func Str2Uint

func Str2Uint(source string) (any, error)

func Str2Uint16

func Str2Uint16(source string) (any, error)

func Str2Uint32

func Str2Uint32(source string) (any, error)

func Str2Uint8

func Str2Uint8(source string) (any, error)

func StrNumSuffixInt

func StrNumSuffixInt(str string, mult int) int

StrNumSuffixInt Parse a number with K/M/G suffixes based on thousands (1000) or 2^10 (1024)

func Stream added in v1.0.24

func Stream[T any](source []T, fn func(one T))

func String

func String(obj any) string

func Substring

func Substring(source string, start int, end int) string

func Type2Str

func Type2Str(t reflect.Type) (string, error)

func TypeOf

func TypeOf(obj any) reflect.Type

func Values added in v1.0.24

func Values[T any, K Keyable](source map[K]T) []T

Types

type Dimension added in v1.0.24

type Dimension struct {
	M1  string
	M15 string
	M30 string
	M60 string

	LM1  string
	LM15 string
	LM30 string
	LM60 string
}

func Time2Dimension added in v1.0.24

func Time2Dimension(t time.Time) (*Dimension, error)

type Endian added in v1.0.20

type Endian int8
const (
	LittleEndian Endian = iota
	BigEndian
)

type Keyable added in v1.0.24

type Keyable interface {
	int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | uintptr | float32 | float64 | complex64 | complex128 | string
}

type Numeric added in v1.0.25

type Numeric interface {
	int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | uintptr | float32 | float64 | complex64 | complex128
}

type RegExpError added in v1.0.13

type RegExpError struct {
}

func (RegExpError) Error added in v1.0.13

func (e RegExpError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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