object

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2025 License: MIT Imports: 21 Imported by: 2

Documentation

Index

Constants

View Source
const WX_CURRENCY_UNIT float64 = 100

Variables

This section is empty.

Functions

func ArrayKeyExists

func ArrayKeyExists(key interface{}, m map[interface{}]interface{}) bool

func Bool

func Bool(b bool) *bool

Bool 复制 bool 对象,并返回复制体的指针

func Camel

func Camel(value string) string

*

  • Convert a value to camel case. *
  • @param string value
  • @return string

func ContainsString

func ContainsString(s []string, str string) bool

func ConvertStringMapToString

func ConvertStringMapToString(m *StringMap, separate string) string

func ConvertToCentUnit

func ConvertToCentUnit(amount float64) int

func ConvertToYuanUnit

func ConvertToYuanUnit(amount int) float64

func EncodeToBytes

func EncodeToBytes(p interface{}) []byte

func Float32

func Float32(f float32) *float32

Float32 复制 float32 对象,并返回复制体的指针

func Float64

func Float64(f float64) *float64

Float64 复制 float64 对象,并返回复制体的指针

func GetHashMapKV

func GetHashMapKV(maps StringMap) (keys []string, values []interface{})

func GetJoinedWithKSort

func GetJoinedWithKSort(params *StringMap) string

func GetModelTags

func GetModelTags(t reflect.Type, tagName string) (tags []string)

--- ---

func GetStringMapKV

func GetStringMapKV(maps StringMap) (keys []string, values []string)

func HashMapToStructure

func HashMapToStructure(mapObj *HashMap, obj interface{}) (err error)

func Implode

func Implode(glue string, arrayStrs []string) string

func InArray

func InArray(needle interface{}, hystack interface{}) bool

func InHash

func InHash(val interface{}, hash *HashMap) (exists bool, key string)

------------------------------- Search --------------------------------------------

func InStringMap

func InStringMap(val string, maps *StringMap) (exists bool, keys []string)

func Int

func Int(i int) *int

Int 复制 int 对象,并返回复制体的指针

func Int32

func Int32(i int32) *int32

Int32 复制 int64 对象,并返回复制体的指针

func Int64

func Int64(i int64) *int64

Int64 复制 int64 对象,并返回复制体的指针

func IsLower

func IsLower(s string) bool

*

  • Check for lowercase character(s)
  • @param string str <p>
  • The input string.
  • </p>
  • @param string<p>
  • @return bool.

func IsNumeric

func IsNumeric(val interface{}, trueNumber bool) bool

func IsObjectNil

func IsObjectNil(obj interface{}) bool

func IsUpper

func IsUpper(s string) bool

*

  • Check for uppercase character(s)
  • @param string str <p>
  • The input string.
  • </p>
  • @param string<p>
  • @return bool.

func JsonDecode

func JsonDecode(data []byte, v interface{}) error

func JsonEncode

func JsonEncode(v interface{}) (string, error)

func JsonEscape

func JsonEscape(str string) (string, error)

func LCFirst

func LCFirst(str string) string

*

  • Make a string's first character lowercase
  • @param string str <p>
  • The input string.
  • </p>
  • @return string the resulting string.

func LoadObjectFromFile

func LoadObjectFromFile(jsonPath string, obj interface{}) (err error)

func Lower

func Lower(value string) string

*

  • Convert the given string to lower-case. *
  • @param string $value
  • @return string

func Map2Xml

func Map2Xml(obj *HashMap, isSub bool) (strXML string)

func OpenYMLFile

func OpenYMLFile(yamlFile string, yamlObject interface{}) (err error)

func QuickRandom

func QuickRandom(length int) string

func RandStringBytesMask

func RandStringBytesMask(n int) string

func RegexpReplace

func RegexpReplace(pattern string, replacement string, subject string) string

*

  • Replace by regex *
  • @param string $value
  • @return string

func SaveObjectToFile

func SaveObjectToFile(obj interface{}, filePath string, perm fs.FileMode) (err error)

func SaveYMLFile

func SaveYMLFile(yamlObject interface{}, savePath string, perm fs.FileMode) (err error)

func SearchInArray

func SearchInArray(val interface{}, array interface{}) (exists bool, index int)

func Shuffle

func Shuffle(str string) string

func Snake

func Snake(value string, delimiter string) string

*

  • Convert a string to snake case. *
  • @param string $value
  • @param string $delimiter
  • @return string

func Str2Xml

func Str2Xml(in string) string

func String

func String(s string) *string

String 复制 string 对象,并返回复制体的指针

func StringMap2Xml

func StringMap2Xml(obj *StringMap) (strXML string)

func StructToJson

func StructToJson(obj interface{}) (strJson string, err error)

func StructToMap

func StructToMap(obj interface{}) (newMap map[string]interface{}, err error)

------------------------------- Conversion ---------------------------------------

func Studly

func Studly(value string) string

*

  • Convert a value to studly caps case. *
  • @param string value
  • @return string

func Time

func Time(t time.Time) *time.Time

Time 复制 time.Time 对象,并返回复制体的指针

func UCWords

func UCWords(str string) string

*

  • Uppercase the first character of each word in a string
  • @param string str <p>
  • The input string.
  • </p>
  • @param string delimiters [optional] <p>
  • @return string the modified string.

func UniqueID

func UniqueID(prefix string) string

func Upper

func Upper(value string) string

*

  • Convert the given string to upper-case. *
  • @param string $value
  • @return string

func Xml2HashMap

func Xml2HashMap(b []byte) (m map[string]interface{}, err error)

Types

type AnyMap

type AnyMap map[interface{}]interface{}

type Array

type Array []interface{}

type Attribute

type Attribute struct {
	Attributes HashMap
}

func NewAttribute

func NewAttribute(attributes *HashMap) *Attribute

func (*Attribute) CheckRequiredAttributes

func (attr *Attribute) CheckRequiredAttributes() error

func (*Attribute) Get

func (attr *Attribute) Get(attribute string, defaultValue interface{}) interface{}

func (*Attribute) GetAttribute

func (attr *Attribute) GetAttribute(name string, defaultValue interface{}) interface{}

func (*Attribute) GetAttributes

func (attr *Attribute) GetAttributes() *HashMap

func (*Attribute) GetRequired

func (attr *Attribute) GetRequired() []string

func (*Attribute) GetString

func (attr *Attribute) GetString(attribute string, defaultValue string) string

func (*Attribute) Has

func (attr *Attribute) Has(key string) bool

func (*Attribute) IsRequired

func (attr *Attribute) IsRequired(attribute string) bool

func (*Attribute) Merge

func (attr *Attribute) Merge(attributes *HashMap) *Attribute

func (*Attribute) SetAttribute

func (attr *Attribute) SetAttribute(name string, value interface{}) *Attribute

func (*Attribute) SetAttributes

func (attr *Attribute) SetAttributes(attributes *HashMap) *Attribute

type Collection

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

func NewCollection

func NewCollection(items *HashMap) *Collection

func (*Collection) Add

func (c *Collection) Add(key string, value interface{})

func (*Collection) All

func (c *Collection) All() *HashMap

func (*Collection) Count

func (c *Collection) Count() int

func (*Collection) Except

func (c *Collection) Except(keys []string) HashMap

func (*Collection) First

func (c *Collection) First() interface{}

func (*Collection) Forget

func (c *Collection) Forget(key string)

func (*Collection) Get

func (c *Collection) Get(key string, defaultValue interface{}) interface{}

Get an item from an hashMap using "dot" notation.

func (*Collection) GetBool

func (c *Collection) GetBool(key string, defaultValue bool) bool

func (*Collection) GetBoolPointer

func (c *Collection) GetBoolPointer(key string, defaultValue bool) *bool

func (*Collection) GetDateTime

func (c *Collection) GetDateTime(key string, defaultValue time.Time) time.Time

func (*Collection) GetDateTimePointer

func (c *Collection) GetDateTimePointer(key string, defaultValue time.Time) *time.Time

func (*Collection) GetFloat32

func (c *Collection) GetFloat32(key string, defaultValue float64) float32

func (*Collection) GetFloat32Pointer

func (c *Collection) GetFloat32Pointer(key string, defaultValue float64) *float32

func (*Collection) GetFloat64

func (c *Collection) GetFloat64(key string, defaultValue float64) float64

func (*Collection) GetFloat64Array

func (c *Collection) GetFloat64Array(key string, defaultValue []float64) []float64

func (*Collection) GetFloat64Pointer

func (c *Collection) GetFloat64Pointer(key string, defaultValue float64) *float64

func (*Collection) GetInt

func (c *Collection) GetInt(key string, defaultValue int) int

func (*Collection) GetInt16

func (c *Collection) GetInt16(key string, defaultValue int16) int16

func (*Collection) GetInt16Pointer

func (c *Collection) GetInt16Pointer(key string, defaultValue int16) *int16

func (*Collection) GetInt32

func (c *Collection) GetInt32(key string, defaultValue int32) int32

func (*Collection) GetInt32Pointer

func (c *Collection) GetInt32Pointer(key string, defaultValue int32) *int32

func (*Collection) GetInt64

func (c *Collection) GetInt64(key string, defaultValue int64) int64

func (*Collection) GetInt64Pointer

func (c *Collection) GetInt64Pointer(key string, defaultValue int64) *int64

func (*Collection) GetInt8

func (c *Collection) GetInt8(key string, defaultValue int8) int8

func (*Collection) GetInt8Pointer

func (c *Collection) GetInt8Pointer(key string, defaultValue int8) *int8

func (*Collection) GetIntArray

func (c *Collection) GetIntArray(key string, defaultValue []int) []int

func (*Collection) GetIntPointer

func (c *Collection) GetIntPointer(key string, defaultValue int) *int

func (*Collection) GetInterfaceArray

func (c *Collection) GetInterfaceArray(key string, defaultValue []interface{}) []interface{}

func (*Collection) GetNullString

func (c *Collection) GetNullString(key string, defaultValue string) NullString

func (*Collection) GetString

func (c *Collection) GetString(key string, defaultValue string) string

func (*Collection) GetStringArray

func (c *Collection) GetStringArray(key string, defaultValue []string) []string

func (*Collection) GetStringPointer

func (c *Collection) GetStringPointer(key string, defaultValue string) *string

func (*Collection) Has

func (c *Collection) Has(key string) bool

func (*Collection) Last

func (c *Collection) Last() interface{}

func (*Collection) Merge

func (c *Collection) Merge(items *HashMap) HashMap

func (*Collection) Only

func (c *Collection) Only(keys []string) (result *HashMap)

func (*Collection) Set

func (c *Collection) Set(key string, value interface{})

func (*Collection) ToHashMap

func (c *Collection) ToHashMap() *HashMap

func (*Collection) ToJson

func (c *Collection) ToJson(option int) (string, error)

func (*Collection) ToString

func (c *Collection) ToString() string

func (*Collection) Unserialize

func (c *Collection) Unserialize(serialized string) *HashMap

type HashMap

type HashMap map[string]interface{}

func FilterEmptyHashMap

func FilterEmptyHashMap(mapData *HashMap) (filteredMap *HashMap)

------------------------------- Filter --------------------------------------------

func MergeHashMap

func MergeHashMap(toMap *HashMap, subMaps ...*HashMap) *HashMap

------------------------------- Merge --------------------------------------------

func ReplaceHashMapRecursive

func ReplaceHashMapRecursive(toMap *HashMap, subMaps ...*HashMap) *HashMap

------------------------------- Replace --------------------------------------------

func StructToHashMap

func StructToHashMap(obj interface{}) (newMap *HashMap, err error)

func StructToHashMapWithXML

func StructToHashMapWithXML(obj interface{}) (newMap *HashMap, err error)

func Xml2Map

func Xml2Map(b []byte) (m HashMap, err error)

func (*HashMap) Get

func (m *HashMap) Get(key string) interface{}

type NullString

type NullString struct {
	sql.NullString
}

func NewNullString

func NewNullString(String string, Valid bool) NullString

func (*NullString) MarshalJSON

func (v *NullString) MarshalJSON() ([]byte, error)

func (*NullString) UnmarshalJSON

func (v *NullString) UnmarshalJSON(data []byte) error

type StringMap

type StringMap map[string]string
var (
	/**
	 * The cache of snake-cased words.
	 *
	 * @var array
	 */
	SnakeCache StringMap

	/**
	 * The cache of camel-cased words.
	 *
	 * @var array
	 */
	CamelCache StringMap

	/**
	 * The cache of studly-cased words.
	 *
	 * @var array
	 */
	StudlyCache StringMap

	/**
	 * The callback that should be used to generate UUIDs.
	 *
	 * @var callable
	 */
	UidFactory StringMap
)

func FilterEmptyStringMap

func FilterEmptyStringMap(mapData *StringMap) (filteredMap *StringMap)

------------------------------- Filter --------------------------------------------

func HashMapToStringMap

func HashMapToStringMap(obj *HashMap) (newMap *StringMap, err error)

func MergeStringMap

func MergeStringMap(toStringMap *StringMap, subStringMaps ...*StringMap) *StringMap

------------------------------- Merge --------------------------------------------

func ReplaceStringMapRecursive

func ReplaceStringMapRecursive(toMap *StringMap, subMaps ...*StringMap) *StringMap

------------------------------- Replace --------------------------------------------

func StructToStringMap

func StructToStringMap(obj interface{}) (newMap *StringMap, err error)

func StructToStringMapWithTag

func StructToStringMapWithTag(obj interface{}, tag string) (newMap *StringMap, err error)

Jump to

Keyboard shortcuts

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