fstypes

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: May 7, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SliceCopy added in v0.0.6

func SliceCopy[S ~[]T, T any](a S) S

SliceCopy 复制一个 slice

若原 slice == nil 会返回 nil
其他情况总是返回一个新的 slice,及时 len == 0

func SliceDelete added in v0.0.6

func SliceDelete[S ~[]T, T comparable](arr S, values ...T) S

func SliceHas added in v0.0.6

func SliceHas[S ~[]T, T comparable](arr S, values ...T) bool

func SliceIndex added in v0.0.6

func SliceIndex[S ~[]T, T comparable](arr S, values ...T) int

func SliceJoin added in v0.0.6

func SliceJoin[T any](arr []T, sep string) string

func SliceJoinFormat added in v0.0.6

func SliceJoinFormat[T any](arr []T, format func(val T) string, sep string) string

func SliceMerge added in v0.0.5

func SliceMerge[S ~[]T, T any](items ...S) S

SliceMerge merge 多个 slice 为一个,并最终返回一个新的 slice

func SliceUnique added in v0.0.6

func SliceUnique[S ~[]T, T comparable](arr S) S

func SliceValuesAllow added in v0.0.6

func SliceValuesAllow[T comparable](values []T, allow []T) error

func SubStr added in v0.0.6

func SubStr(str string, offset int, length int) string

SubStr 截取字符串

str     待截取字符串
offset  偏移值。
        当 offset >= 0 时,从 offset 开始截取;
        当 offset < 0 时,从结尾倒数 offset 个字符开始截取
length  截取长度。
        当 length == 0 时,返回空字符串
        当 length > 0 时,最多返回  length 长度的字符串
        当 length < 0 时,截取到倒数 length 个字符,若位置在 offset 之前,则返回空字符串

Types

type Complex added in v0.0.5

type Complex interface {
	~complex64 | ~complex128
}

type EnableStatus added in v0.0.5

type EnableStatus int32

EnableStatus enable and disable status, default value is enable

func (*EnableStatus) Disable added in v0.0.5

func (es *EnableStatus) Disable()

Disable set status disable

func (*EnableStatus) Enable added in v0.0.5

func (es *EnableStatus) Enable()

Enable set status enable

func (*EnableStatus) IsEnable added in v0.0.5

func (es *EnableStatus) IsEnable() bool

IsEnable return is enable

func (*EnableStatus) SetEnable added in v0.0.5

func (es *EnableStatus) SetEnable(enable bool)

SetEnable set status

func (*EnableStatus) String added in v0.0.5

func (es *EnableStatus) String() string

String return status desc

type Float added in v0.0.5

type Float interface {
	~float32 | ~float64
}

type GroupEnableStatus added in v0.0.5

type GroupEnableStatus struct {

	// Default 未设置时的默认值
	Default bool
	// contains filtered or unexported fields
}

GroupEnableStatus 一组状态,默认未设置会返回 false

func (*GroupEnableStatus) IsEnable added in v0.0.5

func (gs *GroupEnableStatus) IsEnable(key any) bool

IsEnable 获取状态

func (*GroupEnableStatus) Range added in v0.0.5

func (gs *GroupEnableStatus) Range(fn func(key any, enable bool) bool)

Range 遍历所有已设置的值

func (*GroupEnableStatus) SetAllEnable added in v0.0.5

func (gs *GroupEnableStatus) SetAllEnable(enable bool)

SetAllEnable 设置所有的状态,设置后,也会调整默认状态为此值

如 默认值为 false,若 key="key123" 未设置,调用 IsEnable("key123") 会返回 false,
当 SetAllEnable(true) 之后,再次调用 IsEnable("key123") 会返回 true

func (*GroupEnableStatus) SetEnable added in v0.0.5

func (gs *GroupEnableStatus) SetEnable(key any, enable bool)

SetEnable 设置状态

func (*GroupEnableStatus) String added in v0.0.5

func (gs *GroupEnableStatus) String() string

String 打印出所有已经设置的状态信息

type Integer added in v0.0.5

type Integer interface {
	Signed | Unsigned
}

type Ordered added in v0.0.5

type Ordered interface {
	Integer | Float | ~string
}

type Signed added in v0.0.5

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type String

type String string

String 字符串

func (String) Int16Slice added in v0.0.5

func (s String) Int16Slice(sep string) ([]int16, error)

Int16Slice 转换为 []int16

func (String) Int32Slice added in v0.0.5

func (s String) Int32Slice(sep string) ([]int32, error)

Int32Slice 转换为 []int32

func (String) Int64Slice added in v0.0.5

func (s String) Int64Slice(sep string) ([]int64, error)

Int64Slice 转换为 []int32

func (String) Int8Slice added in v0.0.5

func (s String) Int8Slice(sep string) ([]int8, error)

Int8Slice 转换为 []int8

func (String) IntSlice added in v0.0.5

func (s String) IntSlice(sep string) ([]int, error)

IntSlice 转换为 []int

func (String) Split

func (s String) Split(sep string) []string

Split 转换为 []string 会剔除掉空字符串,如 `a, c,` -> []string{"a","c"}

func (String) SubStr added in v0.0.6

func (s String) SubStr(offset int, length int) String

SubStr 截取字符串 @see SubStr

func (String) Uint16Slice added in v0.0.5

func (s String) Uint16Slice(sep string) ([]uint16, error)

Uint16Slice 转换为 []uint16

func (String) Uint32Slice added in v0.0.5

func (s String) Uint32Slice(sep string) ([]uint32, error)

Uint32Slice 转换为 []uint32

func (String) Uint64Slice added in v0.0.5

func (s String) Uint64Slice(sep string) ([]uint64, error)

Uint64Slice 转换为 []uint64

func (String) Uint8Slice added in v0.0.5

func (s String) Uint8Slice(sep string) ([]uint8, error)

Uint8Slice 转换为 []uint8

func (String) UintSlice added in v0.0.5

func (s String) UintSlice(sep string) ([]uint, error)

UintSlice 转换为 []uint

type StringSlice

type StringSlice []string

StringSlice alias off []string

func (*StringSlice) Delete added in v0.0.5

func (ss *StringSlice) Delete(values ...string)

Delete 删除对应的值

func (StringSlice) Has added in v0.0.5

func (ss StringSlice) Has(value string) bool

Has 是否包含指定的值

func (StringSlice) Unique

func (ss StringSlice) Unique() StringSlice

Unique uniq

type Unsigned added in v0.0.5

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

Jump to

Keyboard shortcuts

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