convert

package
v0.0.0-...-dc5dadc Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool2Int

func Bool2Int(b bool) int64

Bool2Int converts a boolean to an integer Bool2Int 将布尔值转换为整数 b: boolean value // 布尔值 return: 1 if true, 0 if false // 返回值: true 返回 1,false 返回 0

func Camel2Case

func Camel2Case(name string) string

驼峰式写法转为下划线写法

func Case2Camel

func Case2Camel(name string) string

下划线写法转为驼峰写法

func Case2LowerCamel

func Case2LowerCamel(name string) string

下划线写法转为驼峰写法

func GetCopyStructFields

func GetCopyStructFields(source interface{}, target interface{}) []interface{}

func GetStructFieldNames

func GetStructFieldNames(input interface{}) []string

GetStructFields 返回传入结构体的所有字段名

func Lcfirst

func Lcfirst(str string) string

首字母小写

func MapAnyToMapStr

func MapAnyToMapStr(p map[string]interface{}) map[string]string

func StructAssign

func StructAssign(src any, dst any) any

CopyStruct dst 目标结构体,src 源结构体 它会把src与dst的相同字段名的值,复制到dst中

func StructAssign2

func StructAssign2(src any, dst any) any

CopyStruct dst 目标结构体,src 源结构体 它会把src与dst的相同字段名的值,复制到dst中

func StructToMap

func StructToMap(param any, data map[string]interface{}) error

*

  • @Description: 结构体map互转
  • @param param interface{} 需要被转的数据
  • @param data interface{} 转换完成后的数据 需要用引用传进来
  • @return []string{}

func StructToMapByReflect

func StructToMapByReflect(obj any) map[string]any

func StructToModelMap

func StructToModelMap(param any, data map[string]any, key string) error

func Ucfirst

func Ucfirst(str string) string

首字母大写

Types

type Buffer

type Buffer struct {
	*bytes.Buffer
}

内嵌bytes.Buffer,支持连写

func NewBuffer

func NewBuffer() *Buffer

func (*Buffer) Append

func (b *Buffer) Append(i interface{}) *Buffer

type StrTo

type StrTo string

func (StrTo) Int

func (s StrTo) Int() (int, error)

func (StrTo) Int64

func (s StrTo) Int64() (int64, error)

func (StrTo) MustInt

func (s StrTo) MustInt() int

func (StrTo) MustInt64

func (s StrTo) MustInt64() int64

func (StrTo) MustToSize

func (s StrTo) MustToSize(defaultVal int64) int64

MustToSize converts a string to byte size, returns default value if error occurs MustToSize 将字符串转换为字节大小,如果出错返回默认值

func (StrTo) MustUInt32

func (s StrTo) MustUInt32() uint32

func (StrTo) String

func (s StrTo) String() string

func (StrTo) ToSize

func (s StrTo) ToSize() (int64, error)

ToSize converts a string to byte size, supporting KB, MB, B suffixes ToSize 将字符串转换为字节大小,支持 KB, MB, B 后缀

func (StrTo) UInt32

func (s StrTo) UInt32() (uint32, error)

Jump to

Keyboard shortcuts

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