util

package
v1.0.8-pro Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2023 License: MIT Imports: 14 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64Decode

func Base64Decode(data string) string

Base64Decode

func Base64Encode

func Base64Encode(data string) string

Base64Encode

func FileExist

func FileExist(path string) (bool, error)

FileExist check file exist returnes true, else false.

func FileFindAllFileChildren

func FileFindAllFileChildren(path, suffix string) ([]string, error)

FileFindAllFileChildren suffix is "" then search the path children all files suffix is not "" then search the path children files suffix is param suffix

func FileIsDir

func FileIsDir(path string) (bool, error)

FileIsDir check file exist and file is folder

func FolderNotExistMkdir

func FolderNotExistMkdir(path string) error

FolderNotExistMkdir check path folder is exist, if not exist then mkdirall the path else os.Stat(path) os.IsNotExist false, then return err, else return nil so used the method then check this err == nil then success.

func IP

func IP() (string, error)

IP

func MD5

func MD5(bt []byte) string

MD5

func MD5File

func MD5File(r io.Reader) string

MD5File

func Max

func Max[T NumberGenericity](a, b T) T

func Min

func Min[T NumberGenericity](a, b T) T

func Now

func Now() string

Now zh - yyyy-MM-dd HH:mm:ss

func Object2Tag

func Object2Tag(obj any, tag string) (map[string]string, error)

func PanicFalse

func PanicFalse(guard bool, format string, params ...any)

PanicFalse

func PanicTrue

func PanicTrue(guard bool, format string, params ...any)

PanicTrue

func RandString

func RandString(base string, n int) string

RandString randomly generate a specified length string based on the given string

func SliceContain

func SliceContain[T comparable](vs []T, v T) bool

SliceContain check the v in vs slice

func SliceDistinct

func SliceDistinct[T comparable](vs ...T) []T

SliceDistinct slice remove duplicates

func SliceMaxNumber

func SliceMaxNumber[T NumberGenericity](vs []T) T

SliceMaxNumber

func SliceMinNumber

func SliceMinNumber[T NumberGenericity](vs []T) T

SliceMinNumber

func ToJSON

func ToJSON(obj any) string

ToJSON

func UID

func UID() string

Types

type FloatGenericity

type FloatGenericity interface {
	float32 | float64
}

type IntGenericity

type IntGenericity interface {
	int | int8 | int16 | int32 | int64
}

type NumberGenericity

type NumberGenericity interface {
	IntGenericity | UIntGenericity | FloatGenericity
}

type Stream

type Stream[T any] interface {
	Length() int
	Skip(i uint) Stream[T]
	Limit(i uint) Stream[T]
	Filter(func(v T) bool) Stream[T]
	ForEach(func(v T) T)
	Do() Stream[T]
	Get() []T
	Set(vs []T) Stream[T]
}

type StreamArray

type StreamArray[T any] struct {
	// contains filtered or unexported fields
}

func NewStreamArray

func NewStreamArray[T any](s []T) *StreamArray[T]

func (*StreamArray[T]) Do

func (s *StreamArray[T]) Do() Stream[T]

func (*StreamArray[T]) Filter

func (s *StreamArray[T]) Filter(f func(v T) bool) Stream[T]

func (*StreamArray[T]) ForEach

func (s *StreamArray[T]) ForEach(f func(v T) T)

func (*StreamArray[T]) Get

func (s *StreamArray[T]) Get() []T

func (*StreamArray[T]) Length

func (s *StreamArray[T]) Length() int

func (*StreamArray[T]) Limit

func (s *StreamArray[T]) Limit(i uint) Stream[T]

func (*StreamArray[T]) Set

func (s *StreamArray[T]) Set(vs []T) Stream[T]

func (*StreamArray[T]) Skip

func (s *StreamArray[T]) Skip(i uint) Stream[T]

type UIntGenericity

type UIntGenericity interface {
	uint | uint8 | uint16 | uint32 | uint64
}

Jump to

Keyboard shortcuts

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