Documentation
¶
Overview ¶
Package structs contains various utilities functions to work with structs.
Index ¶
- Constants
- func FillMap(s interface{}, out map[string]interface{})
- func FillMapWithTag(s interface{}, out map[string]interface{}, tagName string)
- func HasZero(s interface{}) bool
- func HasZeroWithTag(s interface{}, tagName string) bool
- func Int(s interface{}) []int
- func Int16(s interface{}) []int16
- func Int32(s interface{}) []int32
- func Int64(s interface{}) []int64
- func Int64Field(s interface{}, fieldName string) []int64
- func Int8(s interface{}) []int8
- func IntField(s interface{}, fieldName string) []int
- func IsStruct(s interface{}) bool
- func IsZero(s interface{}) bool
- func IsZeroWithTag(s interface{}, tagName string) bool
- func IteratorStructField(s interface{}, tagName string, f func(fv reflect.StructField) bool)
- func KeysIntOfMap(m interface{}) []int64
- func KeysOfMap(m interface{}) []string
- func Map(s interface{}) map[string]interface{}
- func MapSlice(s interface{}) []map[string]interface{}
- func MapSliceWithTag(s interface{}, tagName string) []map[string]interface{}
- func MapWithTag(s interface{}, tagName string) map[string]interface{}
- func Name(s interface{}) string
- func Names(s interface{}) []string
- func NamesWithTag(s interface{}, tagName string) []string
- func String(s interface{}) []string
- func StringField(s interface{}, fieldName string) []string
- func Uint(s interface{}) []uint
- func Uint16(s interface{}) []uint16
- func Uint32(s interface{}) []uint32
- func Uint64(s interface{}) []uint64
- func Uint64Field(s interface{}, fieldName string) []uint64
- func Uint8(s interface{}) []uint8
- func UintField(s interface{}, fieldName string) []uint
- func Values(s interface{}) []interface{}
- func ValuesWithTag(s interface{}, tagName string) []interface{}
- type Field
- func (f *Field) CanInterface() bool
- func (f *Field) CanSet() bool
- func (f *Field) Field(name string) (*Field, bool)
- func (f *Field) Fields() []*Field
- func (f *Field) IsAnonymous() bool
- func (f *Field) IsExported() bool
- func (f *Field) IsZero() bool
- func (f *Field) Kind() reflect.Kind
- func (f *Field) MustField(name string) *Field
- func (f *Field) Name() string
- func (f *Field) Set(val interface{}) error
- func (f *Field) SetZero() error
- func (f *Field) Tag(key string) string
- func (f *Field) Value() interface{}
- type Struct
- func (s *Struct) Field(name string) (*Field, bool)
- func (s *Struct) Fields() []*Field
- func (s *Struct) FillMap(out map[string]interface{})
- func (s *Struct) HasZero() (b bool)
- func (s *Struct) IsZero() (b bool)
- func (s *Struct) Map() map[string]interface{}
- func (s *Struct) MustField(name string) *Field
- func (s *Struct) Name() string
- func (s *Struct) Names() []string
- func (s *Struct) SetTagName(tagName string) *Struct
- func (s *Struct) Values() []interface{}
- type StructSlice
- func (s *StructSlice) Int16() []int16
- func (s *StructSlice) Int32() []int32
- func (s *StructSlice) Int64() []int64
- func (s *StructSlice) Int64Field(fieldName string) []int64
- func (s *StructSlice) Int8() []int8
- func (s *StructSlice) IntField(fieldName string) []int
- func (s *StructSlice) IntSlice() []int
- func (s *StructSlice) Name() string
- func (s *StructSlice) String() []string
- func (s *StructSlice) StringField(fieldName string) []string
- func (s *StructSlice) Uint() []uint
- func (s *StructSlice) Uint16() []uint16
- func (s *StructSlice) Uint32() []uint32
- func (s *StructSlice) Uint64() []uint64
- func (s *StructSlice) Uint64Field(fieldName string) []uint64
- func (s *StructSlice) Uint8() []uint8
- func (s *StructSlice) UintField(fieldName string) []uint
Examples ¶
Constants ¶
const DefaultTagName = "map" // struct's field default tag name
DefaultTagName is the default tag name for struct fields which provides a more granular to tweak certain structs. Lookup the necessary functions for more info.
Variables ¶
This section is empty.
Functions ¶
func FillMap ¶
func FillMap(s interface{}, out map[string]interface{})
FillMap is the same as Map. Instead of returning the output, it fills the given map.
func FillMapWithTag ¶ added in v0.0.2
FillMapWithTag is the same as MapTag(). Instead of returning the output, it fills the given map.
func HasZero ¶
func HasZero(s interface{}) bool
HasZero returns true if any field is equal to a zero value. For more info refer to Struct types HasZero() method. It panics if s's kind is not struct.
Example ¶
// Let's define an Access struct. Note that the "Enabled" field is not // going to be checked because we added the "map" tag to the field. type Access struct { Name string LastAccessed time.Time Number int Enabled bool `map:"-"` } // Name and Number is not initialized. a := &Access{ LastAccessed: time.Now(), } hasZeroA := HasZero(a) // Name and Number is initialized. b := &Access{ Name: "Fatih", LastAccessed: time.Now(), Number: 12345, } hasZeroB := HasZero(b) fmt.Printf("%#v\n", hasZeroA) fmt.Printf("%#v\n", hasZeroB)
Output: true false
func HasZeroWithTag ¶ added in v0.0.2
HasZeroWithTag is the same as HasZero() but with tagName.
func Int ¶ added in v0.0.5
func Int(s interface{}) []int
Int returns a slice of int. For more info refer to Slice types Int() method.
func Int16 ¶ added in v0.0.5
func Int16(s interface{}) []int16
Int16 returns a slice of int16. For more info refer to Slice types Int16() method.
func Int32 ¶ added in v0.0.5
func Int32(s interface{}) []int32
Int32 returns a slice of int32. For more info refer to Slice types Int32() method.
func Int64 ¶ added in v0.0.5
func Int64(s interface{}) []int64
Int64 returns a slice of int64. For more info refer to Slice types Int64() method.
func Int64Field ¶ added in v0.0.5
Int64Field returns a slice of int64. For more info refer to Slice types Int64Field() method.
func Int8 ¶ added in v0.0.5
func Int8(s interface{}) []int8
Int8 returns a slice of int8. For more info refer to Slice types Int8() method.
func IntField ¶ added in v0.0.5
IntField returns a slice of int. For more info refer to Slice types IntField() method.
func IsStruct ¶
func IsStruct(s interface{}) bool
IsStruct returns true if the given variable is a struct or a pointer to struct.
func IsZero ¶
func IsZero(s interface{}) bool
IsZero returns true if all fields is equal to a zero value. For more info refer to Struct types IsZero() method. It panics if s's kind is not struct.
Example ¶
type Server struct { Name string ID int32 Enabled bool } // Nothing is initialized a := &Server{} isZeroA := IsZero(a) // Name and Enabled is initialized, but not ID b := &Server{ Name: "Golang", Enabled: true, } isZeroB := IsZero(b) fmt.Printf("%#v\n", isZeroA) fmt.Printf("%#v\n", isZeroB)
Output: true false
func IsZeroWithTag ¶ added in v0.0.2
IsZeroWithTag is the same as IsZero() but with tagName.
func IteratorStructField ¶ added in v0.0.6
func IteratorStructField(s interface{}, tagName string, f func(fv reflect.StructField) bool)
IteratorStructField iterates over struct fields and calls fn func for each. It panics if the s's kind is not struct.
func KeysIntOfMap ¶ added in v0.0.7
func KeysIntOfMap(m interface{}) []int64
KeysIntOfMap return map key slice, need map key is numeric. (int,int8,int16,int32,int64,uint,uint8,uint16,uint32,uint64).
func KeysOfMap ¶ added in v0.0.7
func KeysOfMap(m interface{}) []string
KeysOfMap return map key slice, need map key is string, if is not string, or not a map, it will panic.
func Map ¶
func Map(s interface{}) map[string]interface{}
Map converts the given struct to a map[string]interface{}. For more info refer to Struct types Map() method. It panics if s's kind is not struct.
Example ¶
type Server struct { Name string ID int32 Enabled bool } s := &Server{ Name: "Arslan", ID: 123456, Enabled: true, } m := Map(s) fmt.Printf("%#v\n", m["Name"]) fmt.Printf("%#v\n", m["ID"]) fmt.Printf("%#v\n", m["Enabled"])
Output: "Arslan" 123456 true
Example (OmitEmpty) ¶
// By default field with struct types of zero values are processed too. We // can stop processing them via "omitempty" tag option. type Server struct { Name string `map:",omitempty"` ID int32 `map:"server_id,omitempty"` Location string } // Only add location s := &Server{ Location: "Tokyo", } m := Map(s) // map contains only the Location field fmt.Printf("%v\n", m)
Output: map[Location:Tokyo]
Example (OmitNested) ¶
// By default field with struct types are processed too. We can stop // processing them via "omitnested" tag option. type Server struct { Name string `map:"server_name"` ID int32 `map:"server_id"` Time time.Time `map:"time,omitnested"` // do not convert to map[string]interface{} } t, _ := time.Parse("2006-Jan-02", "2013-Feb-03") s := &Server{ Name: "Zeynep", ID: 789012, Time: t, } m := Map(s) // access them by the custom tags defined above fmt.Printf("%v\n", m["server_name"]) fmt.Printf("%v\n", m["server_id"]) fmt.Printf("%v\n", m["time"].(time.Time))
Output: Zeynep 789012 2013-02-03 00:00:00 +0000 UTC
Example (Tags) ¶
// Custom tags can change the map keys instead of using the fields name type Server struct { Name string `map:"server_name"` ID int32 `map:"server_id"` Enabled bool `map:"enabled"` } s := &Server{ Name: "Zeynep", ID: 789012, } m := Map(s) // access them by the custom tags defined above fmt.Printf("%#v\n", m["server_name"]) fmt.Printf("%#v\n", m["server_id"]) fmt.Printf("%#v\n", m["enabled"])
Output: "Zeynep" 789012 false
func MapSlice ¶ added in v0.0.3
func MapSlice(s interface{}) []map[string]interface{}
MapSlice converts the given struct slice to a []map[string]interface{}. For more info refer to MapSliceWithTag() method
func MapSliceWithTag ¶ added in v0.0.3
MapSliceWithTag converts the given struct slice to a []map[string]interface{} with tagName. It returns empty []map[string]interface{} if s is not a slice struct.
func MapWithTag ¶ added in v0.0.2
MapWithTag same as Map() but with tagName. It panics if s's kind is not struct.
func Name ¶
func Name(s interface{}) string
Name returns the map's type name within its package. It returns an empty string for unnamed types. It panics if s's kind is not struct.
func Names ¶
func Names(s interface{}) []string
Names returns a slice of field names. For more info refer to Struct types Names() method. It panics if s's kind is not struct.
func NamesWithTag ¶ added in v0.0.2
NamesWithTag is the same as Names() but with tagName.
func String ¶ added in v0.0.5
func String(s interface{}) []string
String returns a slice of string. For more info refer to Slice types String() method.
func StringField ¶ added in v0.0.5
StringField returns a slice of string. For more info refer to Slice types StringField() method.
func Uint ¶ added in v0.0.5
func Uint(s interface{}) []uint
Uint returns a slice of uint. For more info refer to Slice types Uint() method.
func Uint16 ¶ added in v0.0.5
func Uint16(s interface{}) []uint16
Uint16 returns a slice of uint16. For more info refer to Slice types Uint16() method.
func Uint32 ¶ added in v0.0.5
func Uint32(s interface{}) []uint32
Uint32 returns a slice of uint32. For more info refer to Slice types Uint32() method.
func Uint64 ¶ added in v0.0.5
func Uint64(s interface{}) []uint64
Uint64 returns a slice of uint64. For more info refer to Slice types Uint64() method.
func Uint64Field ¶ added in v0.0.5
Uint64Field returns a slice of uint64. For more info refer to Slice types Uint64Field() method.
func Uint8 ¶ added in v0.0.5
func Uint8(s interface{}) []uint8
Uint8 returns a slice of uint8. For more info refer to Slice types Uint8() method.
func UintField ¶ added in v0.0.5
UintField returns a slice of uint. For more info refer to Slice types v() method.
func Values ¶
func Values(s interface{}) []interface{}
Values converts the given s struct's exported field values to a []interface{}. For more info refer to Struct types Values() method. It panics if s's kind is not struct.
Example ¶
type Server struct { Name string ID int32 Enabled bool } s := &Server{ Name: "Fatih", ID: 135790, Enabled: false, } m := Values(s) fmt.Printf("Values: %+v\n", m)
Output: Values: [Fatih 135790 false]
Example (OmitEmpty) ¶
// By default field with struct types of zero values are processed too. We // can stop processing them via "omitempty" tag option. type Server struct { Name string `map:",omitempty"` ID int32 `map:"server_id,omitempty"` Location string } // Only add location s := &Server{ Location: "Ankara", } m := Values(s) // values contains only the Location field fmt.Printf("Values: %+v\n", m)
Output: Values: [Ankara]
Example (Tags) ¶
type Location struct { City string Country string } type Server struct { Name string ID int32 Enabled bool Location Location `map:"-"` // values from location are not included anymore } s := &Server{ Name: "Fatih", ID: 135790, Enabled: false, Location: Location{City: "Ankara", Country: "Turkey"}, } // Let get all values from the struct s. Note that we don't include values // from the Location field m := Values(s) fmt.Printf("Values: %+v\n", m)
Output: Values: [Fatih 135790 false]
func ValuesWithTag ¶ added in v0.0.2
func ValuesWithTag(s interface{}, tagName string) []interface{}
ValuesWithTag is the same as Values() but with tagName.
Types ¶
type Field ¶
type Field struct {
// contains filtered or unexported fields
}
Field represents a single struct field that encapsulates high level functions around the field.
Example ¶
type Person struct { Name string Number int } type Access struct { Person Person HasPermission bool LastAccessed time.Time } access := &Access{ Person: Person{Name: "fatih", Number: 1234567}, LastAccessed: time.Now(), HasPermission: true, } // Create a new Struct type s := New(access) // Get the MustField type for "Person" field p := s.MustField("Person") // Get the underlying "Name field" and print the value of it name := p.MustField("Name") fmt.Printf("Value of Person.Access.Name: %+v\n", name.Value())
Output: Value of Person.Access.Name: fatih
func Fields ¶
func Fields(s interface{}) []*Field
Fields returns a slice of *Field. For more info refer to Struct types Fields() method. It panics if s's kind is not struct.
Example ¶
type Access struct { Name string LastAccessed time.Time Number int } s := &Access{ Name: "Fatih", LastAccessed: time.Now(), Number: 1234567, } fields := Fields(s) for i, field := range fields { fmt.Printf("[%d] %+v\n", i, field.Name()) }
Output: [0] Name [1] LastAccessed [2] Number
Example (Nested) ¶
type Person struct { Name string Number int } type Access struct { Person Person HasPermission bool LastAccessed time.Time } s := &Access{ Person: Person{Name: "fatih", Number: 1234567}, LastAccessed: time.Now(), HasPermission: true, } // Let's get all fields from the struct s. fields := Fields(s) for _, field := range fields { if field.Name() == "Person" { fmt.Printf("Access.Person.Name: %+v\n", field.MustField("Name").Value()) } }
Output: Access.Person.Name: fatih
func FieldsWithTag ¶ added in v0.0.2
FieldsWithTag is the same as Fields() but with tagName.
func (*Field) CanInterface ¶
CanInterface reports whether Interface can be used without panicking.
func (*Field) Field ¶
Field returns the field from a nested struct. The boolean returns whether the field was found (true) or not (false).
func (*Field) Fields ¶
Fields returns a slice of Fields. This is particular handy to get the fields of a nested struct . A struct tag with the content of "-" ignores the checking of that particular field. Example:
// Field is ignored by this package. Field *http.Request `structs:"-"`
It panics if field is not exported or if field's kind is not struct
func (*Field) IsAnonymous ¶
IsAnonymous returns true if the given field is an anonymous field (embedded)
func (*Field) IsExported ¶
IsExported returns true if the given field is exported.
func (*Field) IsZero ¶
IsZero returns true if the given field is not initialized (has a zero value). It panics if the field is not exported.
func (*Field) MustField ¶
Field returns the field from a nested struct. It panics if the nested struct is not exported or if the field was not found.
func (*Field) Set ¶
Set sets the field to given value v. It returns an error if the field is not settable (not addressable or not exported) or if the given value's type doesn't match the fields type.
func (*Field) SetZero ¶
SetZero sets the field to its zero value. It returns an error if the field is not settable (not addressable or not exported).
type Struct ¶
type Struct struct {
// contains filtered or unexported fields
}
Struct encapsulates a struct type to provide several high level functions around the struct.
func New ¶
func New(s interface{}) *Struct
New returns a new *Struct with the struct. It panics if the s's kind is not struct.
Example ¶
type Server struct { Name string ID int32 Enabled bool } server := &Server{ Name: "Arslan", ID: 123456, Enabled: true, } s := New(server) fmt.Printf("Name : %v\n", s.Name()) fmt.Printf("Values : %v\n", s.Values()) fmt.Printf("Value of ID : %v\n", s.MustField("ID").Value())
Output: Name : Server Values : [Arslan 123456 true] Value of ID : 123456
func (*Struct) Field ¶
Field returns a new Field struct that provides several high level functions around a single struct field entity. The boolean returns true if the field was found.
func (*Struct) Fields ¶
Fields returns a slice of Fields. A struct tag with the content of "-" ignores the checking of that particular field. Example:
// Field is ignored by this package. Field bool `map:"-"`
It panics if s's kind is not struct.
func (*Struct) FillMap ¶
FillMap is the same as Map. Instead of returning the output, it fills the given map.
func (*Struct) HasZero ¶
HasZero returns true if a field in a struct is not initialized (zero value). A struct tag with the content of "-" ignores the checking of that particular field. Example:
// Field is ignored by this package. Field bool `map:"-"`
A value with the option of "omitnested" stops iterating further if the type is a struct. Example:
// Field is not processed further by this package. Field time.Time `map:"myName,omitnested"` Field *http.Request `map:",omitnested"`
Note that only exported fields of a struct can be accessed, non exported fields will be neglected. It panics if s's kind is not struct.
func (*Struct) IsZero ¶
IsZero returns true if all fields in a struct is a zero value (not initialized) A struct tag with the content of "-" ignores the checking of that particular field. Example:
// Field is ignored by this package. Field bool `map:"-"`
A value with the option of "omitnested" stops iterating further if the type is a struct. Example:
// Field is not processed further by this package. Field time.Time `map:"myName,omitnested"` Field *http.Request `map:",omitnested"`
Note that only exported fields of a struct can be accessed, non exported fields will be neglected. It panics if s's kind is not struct.
func (*Struct) Map ¶
Map converts the given struct to a map[string]interface{}, where the keys of the map are the field names and the values of the map the associated values of the fields. The default key string is the struct field name but can be changed in the struct field's tag value. The "structs" key in the struct's field tag value is the key name. Example:
// Field appears in map as key "myName". Name string `map:"myName"`
A tag value with the content of "-" ignores that particular field. Example:
// Field is ignored by this package. Field bool `map:"-"`
A tag value with the content of "string" uses the stringer to get the value. Example:
// The value will be output of Animal's String() func. // Map will panic if Animal does not implement String(). Field *Animal `map:"field,string"`
A tag value with the option of "flatten" used in a struct field is to flatten its fields in the output map. Example:
// The FieldStruct's fields will be flattened into the output map. FieldStruct time.Time `structs:",flatten"`
A tag value with the option of "omitnested" stops iterating further if the type is a struct. Example:
// Field is not processed further by this package. Field time.Time `map:"myName,omitnested"` Field *http.Request `map:",omitnested"`
A tag value with the option of "omitempty" ignores that particular field if the field value is empty. Example:
// Field appears in map as key "myName", but the field is // skipped if empty. Field string `map:"myName,omitempty"` // Field appears in map as key "MustField" (the default), but // the field is skipped if empty. Field string `map:",omitempty"`
Note that only exported fields of a struct can be accessed, non exported fields will be neglected.
func (*Struct) MustField ¶
MustField returns a new Field struct that provides several high level functions around a single struct field entity. It panics if the field is not found.
func (*Struct) Name ¶
Name returns the map's type name within its package. For more info refer to Name() function.
func (*Struct) Names ¶
Names returns a slice of field names. A struct tag with the content of "-" ignores the checking of that particular field. Example:
// Field is ignored by this package. Field bool `map:"-"`
It panics if s's kind is not struct.
func (*Struct) SetTagName ¶
SetTagName set struct's field tag name, default is DefaultTagName.
func (*Struct) Values ¶
func (s *Struct) Values() []interface{}
Values converts the given s struct's exported field values to a []interface{}. A struct tag with the content of "-" ignores the that particular field. Example:
// Field is ignored by this package. Field int `map:"-"`
A value with the option of "omitnested" stops iterating further if the type is a struct. Example:
// Fields is not processed further by this package. Field time.Time `map:",omitnested"` Field *http.Request `map:",omitnested"`
A tag value with the option of "omitempty" ignores that particular field and is not added to the values if the field value is empty. Example:
// Field is skipped if empty Field string `map:",omitempty"`
Note that only exported fields of a struct can be accessed, non exported fields will be neglected.
type StructSlice ¶ added in v0.0.4
type StructSlice struct {
// contains filtered or unexported fields
}
StructSlice hold a struct slice reflect.value
func NewStructSlice ¶ added in v0.0.4
func NewStructSlice(s interface{}) *StructSlice
NewStructSlice returns a new *Slice with the slice s. It panics if the s's kind is not slice.
func (*StructSlice) Int16 ¶ added in v0.0.5
func (s *StructSlice) Int16() []int16
Int16 extracts the given s slice's every element, which is integer or float, to []int16 by the field. It panics if the s's element is not integer or float, or field is not invalid.
func (*StructSlice) Int32 ¶ added in v0.0.5
func (s *StructSlice) Int32() []int32
Int32 extracts the given s slice's every element, which is integer or float, to []int32 by the field. It panics if the s's element is not integer or float, or field is not invalid.
func (*StructSlice) Int64 ¶ added in v0.0.5
func (s *StructSlice) Int64() []int64
Int64 extracts the given s slice's every element, which is integer or float, to []int64 by the field. It panics if the s's element is not integer or float, or field is not invalid.
func (*StructSlice) Int64Field ¶ added in v0.0.5
func (s *StructSlice) Int64Field(fieldName string) []int64
Int64Field extracts the given s slice's every element, which is struct, to []int64 by the field. It panics if the s's element is not struct, or field is not exits, or the value of field is not integer.
func (*StructSlice) Int8 ¶ added in v0.0.5
func (s *StructSlice) Int8() []int8
Int8 extracts the given s slice's every element, which is integer or float, to []int8 by the field. It panics if the s's element is not integer or float, or field is not invalid.
func (*StructSlice) IntField ¶ added in v0.0.5
func (s *StructSlice) IntField(fieldName string) []int
IntField extracts the given s slice's every element, which is struct, to []int by the field. It panics if the s's element is not struct, or field is not exits, or the value of field is not integer.
func (*StructSlice) IntSlice ¶ added in v0.0.4
func (s *StructSlice) IntSlice() []int
Int extracts the given s slice's every element, which is integer or float, to []int by the field. It panics if the s's element is not integer or float, or field is not invalid.
func (*StructSlice) Name ¶ added in v0.0.4
func (s *StructSlice) Name() string
Name returns the slice's type name within its package. For more info refer to Name() function.
func (*StructSlice) String ¶ added in v0.0.5
func (s *StructSlice) String() []string
String extracts the given s slice's every element, which is integer or float or string, to []string by the field. It panics if the s's element is not integer or float, string, or field is not invalid.
func (*StructSlice) StringField ¶ added in v0.0.5
func (s *StructSlice) StringField(fieldName string) []string
StringField extracts the given s slice's every element, which is struct, to []string by the field. It panics if the s's element is not struct, or field is not exits, or the value of field is not integer or string.
func (*StructSlice) Uint ¶ added in v0.0.5
func (s *StructSlice) Uint() []uint
Uint extracts the given s slice's every element, which is integer or float, to []uint by the field. It panics if the s's element is not integer or float, or field is not invalid.
func (*StructSlice) Uint16 ¶ added in v0.0.5
func (s *StructSlice) Uint16() []uint16
Uint16 extracts the given s slice's every element, which is integer or float, to []uint16 by the field. It panics if the s's element is not integer or float, or field is not invalid.
func (*StructSlice) Uint32 ¶ added in v0.0.5
func (s *StructSlice) Uint32() []uint32
Uint32 extracts the given s slice's every element, which is integer or float, to []uint32 by the field. It panics if the s's element is not integer or float, or field is not invalid.
func (*StructSlice) Uint64 ¶ added in v0.0.5
func (s *StructSlice) Uint64() []uint64
Uint64 extracts the given s slice's every element, which is integer or float, to []uint64 by the field. It panics if the s's element is not integer or float, or field is not invalid.
func (*StructSlice) Uint64Field ¶ added in v0.0.5
func (s *StructSlice) Uint64Field(fieldName string) []uint64
Uint64Field extracts the given s slice's every element, which is struct, to []uint64 by the field. It panics if the s's element is not struct, or field is not exits, or the value of field is not integer.
func (*StructSlice) Uint8 ¶ added in v0.0.5
func (s *StructSlice) Uint8() []uint8
Uint8 extracts the given s slice's every element, which is integer or float, to []uint8 by the field. It panics if the s's element is not integer or float, or field is not invalid.
func (*StructSlice) UintField ¶ added in v0.0.5
func (s *StructSlice) UintField(fieldName string) []uint
UintField extracts the given s slice's every element, which is struct, to []uint by the field. It panics if the s's element is not struct, or field is not exits, or the value of field is not integer.