gx

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2025 License: MIT Imports: 14 Imported by: 7

README

gx

介绍

{以下是 Gitee 平台说明,您可以替换此简介 Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台 无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 https://gitee.com/enterprises}

软件架构

软件架构说明

安装教程
  1. xxxx
  2. xxxx
  3. xxxx
使用说明
  1. xxxx
  2. xxxx
  3. xxxx
参与贡献
  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request
特技
  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/

Documentation

Index

Constants

View Source
const OSDir = 2
View Source
const OSFile = 1
View Source
const OSUnknown = 0

Variables

This section is empty.

Functions

func CompareValue

func CompareValue(x any, y any) bool

比较值,如果是指针类型,会转换为值再比较

func GetValue

func GetValue(v interface{}) interface{}

获取值,如果是指针类型,会返回其所指的值

func IsFalse

func IsFalse(value any) bool

判断值是否为False

func IsMap

func IsMap(v interface{}) bool

判断对象是否map

func IsNil

func IsNil(v any) bool

判断是否nil,支持指针

func IsPointer

func IsPointer(v interface{}) bool

判断数据是否为指针类型

func IsSlice

func IsSlice(v interface{}) bool

判断值是否为切片类型

func IsStruct

func IsStruct(v interface{}) bool

判断数据是否为结构体类型

func IsTrue

func IsTrue(value any) bool

判断值是否为true

func MustParseInt added in v1.0.1

func MustParseInt(s string) int64

func Ptr

func Ptr[T interface{}](value T) *T

获取值指针

Types

type List

type List[T comparable] struct {
	// contains filtered or unexported fields
}

func ListOf

func ListOf[T comparable](items ...T) *List[T]

func (*List[T]) All

func (list *List[T]) All(predicate func(T) bool) bool

所有元素是否都符合条件

func (*List[T]) Any

func (list *List[T]) Any(predicate func(T) bool) bool

是否存在符合条件的元素

func (*List[T]) Append

func (list *List[T]) Append(value T, unique bool) *List[T]

添加元素

func (*List[T]) Clear

func (list *List[T]) Clear() *List[T]

移除所有元素

func (List[T]) Concat

func (list List[T]) Concat(other List[T]) List[T]

func (*List[T]) Contains

func (list *List[T]) Contains(values ...T) bool

包含给定的所有值

func (*List[T]) ContainsAny

func (list *List[T]) ContainsAny(values ...T) bool

包含给定值中的任意一个

func (*List[T]) Filter

func (list *List[T]) Filter(predicate func(T) bool) *List[T]

查找所有符合条件的元素

func (*List[T]) Find

func (list *List[T]) Find(predicate func(T) bool) *T

查找符合条件的元素

func (*List[T]) FindIndex

func (list *List[T]) FindIndex(predicate func(T) bool) int

获取符合条件的元素索引

func (*List[T]) FindLastIndex

func (list *List[T]) FindLastIndex(predicate func(T) bool) int

反向查找符合条件的元素索引

func (*List[T]) First

func (list *List[T]) First() *T

第一个元素

func (*List[T]) ForEach

func (list *List[T]) ForEach(action func(int, T))

遍历

func (List[T]) GroupBy

func (list List[T]) GroupBy(keySelector func(T) string) map[string][]T

分组转换为map

func (*List[T]) Index

func (list *List[T]) Index(value T) int

给定值的索引

func (*List[T]) Insert

func (list *List[T]) Insert(index int, values ...T) *List[T]

在指定索引处插入元素

func (*List[T]) Last

func (list *List[T]) Last() *T

最后一个元素

func (*List[T]) LastIndex

func (list *List[T]) LastIndex(value T) int

func (*List[T]) Len

func (list *List[T]) Len() int

元素数量

func (*List[T]) MapString

func (list *List[T]) MapString(mapper func(int, T) string) []string

转换为字符串切片

func (*List[T]) Remove

func (list *List[T]) Remove(value T) *List[T]

移除元素

func (*List[T]) RemoveAt

func (list *List[T]) RemoveAt(index int) *List[T]

删除指定索引处的元素

func (*List[T]) Reverse

func (list *List[T]) Reverse() *List[T]

颠倒序列

func (List[T]) Slice

func (list List[T]) Slice(startIndex, endIndex int) List[T]

func (*List[T]) Sort

func (list *List[T]) Sort(less func(T, T) bool)

func (*List[T]) ToSlice

func (list *List[T]) ToSlice() []T

元素切片

func (*List[T]) Unique

func (list *List[T]) Unique() *List[T]

去重

type M

type M map[string]any

map[string]any的简化

type Map

type Map[T interface{}] map[string]T

等同于map[string][T]

type Number

type Number interface {
	comdef.Int | comdef.Uint | comdef.Float
}

type OSPath

type OSPath struct {
	// contains filtered or unexported fields
}

func Path

func Path(path string) OSPath

func (OSPath) Exists

func (p OSPath) Exists() bool

func (OSPath) FileInfo

func (p OSPath) FileInfo() (os.FileInfo, error)

func (OSPath) FileType

func (p OSPath) FileType() (string, error)

func (OSPath) Glob

func (p OSPath) Glob(pattern string) ([]string, error)

参考filepath.Glob

func (OSPath) HasPrefix

func (p OSPath) HasPrefix(prefix ...string) bool

func (OSPath) HasSuffix

func (p OSPath) HasSuffix(suffix ...string) bool

func (OSPath) IsDir

func (p OSPath) IsDir() bool

func (OSPath) IsFile

func (p OSPath) IsFile() bool
func (p OSPath) IsSymlink() bool

func (OSPath) Join

func (p OSPath) Join(paths ...string) OSPath

func (OSPath) Mkdir

func (p OSPath) Mkdir(perm fs.FileMode) error

func (OSPath) Open

func (p OSPath) Open() (fs.File, error)

func (OSPath) ReadAll

func (p OSPath) ReadAll() ([]byte, error)

func (OSPath) ReadByteLine

func (p OSPath) ReadByteLine(fn func(bytes []byte, err error)) error

按行读取文件

func (OSPath) ReadLine

func (p OSPath) ReadLine(fn func(line string, err error)) error

按行读取文件

func (OSPath) ReadString

func (p OSPath) ReadString() (string, error)

func (OSPath) Remove

func (p OSPath) Remove() error

func (OSPath) RemoveAll

func (p OSPath) RemoveAll() error

RemoveAll removes path and any children it contains. It removes everything it can but returns the first error it encounters. If the path does not exist, RemoveAll returns nil (no error). If there is an error, it will be of type *PathError.

func (OSPath) String

func (p OSPath) String() string

func (OSPath) Walk

func (p OSPath) Walk(fn func(path OSPath, info fs.FileInfo, err error) error) error

see filepath.Walk

func (OSPath) Zip

func (p OSPath) Zip(output string) error

zip files

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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