util

package
v0.0.0-...-4e5f079 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Address

func Address(addr string) (string, error)

Address return a real ip

func ArrayContainsString

func ArrayContainsString(a []string, e string) bool

ArrayContainsString string contains

func ArrayDistinctInt

func ArrayDistinctInt(src []int) []int

ArrayDistinctInt array distinct

func ArrayIntersectString

func ArrayIntersectString(a []string, b []string) []string

ArrayIntersectString string intersect

func ArrayJoinInt

func ArrayJoinInt(a []int, sep string) string

ArrayJoinInt join int array

func ArrayJoinUint32

func ArrayJoinUint32(a []uint32, sep string) string

ArrayJoinUint32 join uint32 array

func ArrayReverseInt64

func ArrayReverseInt64(a []int64)

ArrayReverseInt64 int64 array reverse

func ArraySortAscInt

func ArraySortAscInt(src []int)

ArraySortAscInt sort int array asc

func ArraySortDescInt

func ArraySortDescInt(src []int)

ArraySortDescInt sort int array desc

func ArrayUnionString

func ArrayUnionString(a []string, b []string) []string

ArrayUnionString string union

func Certificate

func Certificate(host ...string) (tls.Certificate, error)

func Extract

func Extract(addr string) (string, error)

Extract returns a real ip

func GetHttpClientIP

func GetHttpClientIP(request *http.Request) string

func GetTLSConfig

func GetTLSConfig(keyFile, certFile string) (*tls.Config, error)

GetTLSConfig by key and cert

func GetTLSConfigByAddr

func GetTLSConfigByAddr(addr string) (*tls.Config, error)

func GetUUIDV1

func GetUUIDV1() string

func GetUUIDV1WithoutLine

func GetUUIDV1WithoutLine() string

func IPs

func IPs() []string

IPs returns all known ips

func InitPointer

func InitPointer(src reflect.Type) (dst reflect.Value)

InitPointer with value

func InitWithZeroValue

func InitWithZeroValue(src reflect.Type) (dst reflect.Value)

InitWithZeroValue init type with default value

func IsExported

func IsExported(name string) bool

IsExported Is this an exported - upper case - name?

func IsExportedOrBuiltinType

func IsExportedOrBuiltinType(t reflect.Type) bool

IsExportedOrBuiltinType Is this type exported or a builtin?

func Listen

func Listen(addr string, fn func(string) (net.Listener, error)) (net.Listener, error)

Listen takes addr:portmin-portmax and binds to the first available port Example: Listen("localhost:5000-6000", fn)

func SetStructField

func SetStructField(v interface{}, fieldValue interface{}, fieldNames ...string) bool

SetStructField v is ptr to struct

func TrimSpaceAndSlash

func TrimSpaceAndSlash(s string) string

TrimSpaceAndSlash 去除字符串前后 / 和 空格 如果不包含,则返回原字符串

Types

type StructField

type StructField struct {
	Field      reflect.StructField
	FieldName  string
	FieldValue reflect.Value
	IsExist    bool
}

func GetStructField

func GetStructField(v interface{}, fieldNames ...string) *StructField

GetStructField get struct field

func (*StructField) Bool

func (sf *StructField) Bool() (bool, bool)

func (*StructField) BoolE

func (sf *StructField) BoolE() (bool, bool, error)

func (*StructField) Float64

func (sf *StructField) Float64() (float64, bool)

func (*StructField) Float64E

func (sf *StructField) Float64E() (float64, bool, error)

func (*StructField) Int

func (sf *StructField) Int() (int, bool)

func (*StructField) IntE

func (sf *StructField) IntE() (int, bool, error)

func (*StructField) Interface

func (sf *StructField) Interface() (interface{}, bool)

func (*StructField) String

func (sf *StructField) String() (string, bool)

func (*StructField) StringE

func (sf *StructField) StringE() (string, bool, error)

Jump to

Keyboard shortcuts

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