Documentation ¶
Index ¶
- func Clone(e interface{}, deep ...bool) interface{}
- func Convert(src, dest interface{}, safe ...bool) bool
- func IsBool(e interface{}) bool
- func IsBoolMap(e interface{}) bool
- func IsBoolSet(e interface{}) bool
- func IsBoolSlice(e interface{}) bool
- func IsByte(e interface{}) bool
- func IsByteMap(e interface{}) bool
- func IsByteSet(e interface{}) bool
- func IsByteSlice(e interface{}) bool
- func IsChar(e interface{}) bool
- func IsCollection(e interface{}) bool
- func IsElement(e interface{}) bool
- func IsFloat(e interface{}) bool
- func IsFloatMap(e interface{}) bool
- func IsFloatSet(e interface{}) bool
- func IsFloatSlice(e interface{}) bool
- func IsGenericMap(e interface{}) bool
- func IsGenericSet(e interface{}) bool
- func IsGenericSlice(e interface{}) bool
- func IsInt(e interface{}) bool
- func IsIntMap(e interface{}) bool
- func IsIntSet(e interface{}) bool
- func IsIntSlice(e interface{}) bool
- func IsInterface(e interface{}) bool
- func IsInvalid(e interface{}) bool
- func IsMap(e interface{}) bool
- func IsNil(e interface{}) bool
- func IsNumber(e interface{}) bool
- func IsPointer(e interface{}) bool
- func IsRune(e interface{}) bool
- func IsRuneMap(e interface{}) bool
- func IsRuneSet(e interface{}) bool
- func IsRuneSlice(e interface{}) bool
- func IsSet(e interface{}) bool
- func IsSlice(e interface{}) bool
- func IsString(e interface{}) bool
- func IsStringMap(e interface{}) bool
- func IsStringSet(e interface{}) bool
- func IsStringSlice(e interface{}) bool
- func IsStruct(e interface{}) bool
- func IsUint(e interface{}) bool
- func IsUintMap(e interface{}) bool
- func IsUintSet(e interface{}) bool
- func IsUintSlice(e interface{}) bool
- func IsZero(e interface{}) bool
- func PointerOf(e interface{}) interface{}
- func SetZero(dst interface{}) bool
- func ToBool(src interface{}, safe ...bool) (dest bool, ok bool)
- func ToBoolMap(src interface{}, safe ...bool) (dest map[string]bool, ok bool)
- func ToBoolSet(src interface{}, safe ...bool) (dest map[bool]bool, ok bool)
- func ToBoolSlice(src interface{}, safe ...bool) (dest []bool, ok bool)
- func ToByte(src interface{}, safe ...bool) (dest byte, ok bool)
- func ToByteMap(src interface{}, safe ...bool) (dest map[string]byte, ok bool)
- func ToByteSet(src interface{}, safe ...bool) (dest map[byte]bool, ok bool)
- func ToByteSlice(src interface{}, safe ...bool) (dest []byte, ok bool)
- func ToFloat(src interface{}, safe ...bool) (dest float64, ok bool)
- func ToFloatMap(src interface{}, safe ...bool) (dest map[string]float64, ok bool)
- func ToFloatSet(src interface{}, safe ...bool) (dest map[float64]bool, ok bool)
- func ToFloatSlice(src interface{}, safe ...bool) (dest []float64, ok bool)
- func ToInt(src interface{}, safe ...bool) (dest int, ok bool)
- func ToIntMap(src interface{}, safe ...bool) (dest map[string]int, ok bool)
- func ToIntSet(src interface{}, safe ...bool) (dest map[int]bool, ok bool)
- func ToIntSlice(src interface{}, safe ...bool) (dest []int, ok bool)
- func ToInterface(src interface{}, safe ...bool) (dest interface{}, ok bool)
- func ToMap(src interface{}, safe ...bool) (dest map[string]interface{}, ok bool)
- func ToRune(src interface{}, safe ...bool) (dest rune, ok bool)
- func ToRuneMap(src interface{}, safe ...bool) (dest map[string]rune, ok bool)
- func ToRuneSet(src interface{}, safe ...bool) (dest map[rune]bool, ok bool)
- func ToRuneSlice(src interface{}, safe ...bool) (dest []rune, ok bool)
- func ToSet(src interface{}, safe ...bool) (dest map[interface{}]bool, ok bool)
- func ToSlice(src interface{}, safe ...bool) (dest []interface{}, ok bool)
- func ToString(src interface{}, safe ...bool) (dest string, ok bool)
- func ToStringMap(src interface{}, safe ...bool) (dest map[string]string, ok bool)
- func ToStringSet(src interface{}, safe ...bool) (dest map[string]bool, ok bool)
- func ToStringSlice(src interface{}, safe ...bool) (dest []string, ok bool)
- func ToUint(src interface{}, safe ...bool) (dest uint, ok bool)
- func ToUintMap(src interface{}, safe ...bool) (dest map[string]uint, ok bool)
- func ToUintSet(src interface{}, safe ...bool) (dest map[uint]bool, ok bool)
- func ToUintSlice(src interface{}, safe ...bool) (dest []uint, ok bool)
- func ValueOf(e interface{}) interface{}
- func ZeroOf(e interface{}) interface{}
- type Checker
- func (c *Checker) AllClasses() Classes
- func (c *Checker) IsBool() bool
- func (c *Checker) IsBoolMap() bool
- func (c *Checker) IsBoolSet() bool
- func (c *Checker) IsBoolSlice() bool
- func (c *Checker) IsByte() bool
- func (c *Checker) IsByteMap() bool
- func (c *Checker) IsByteSet() bool
- func (c *Checker) IsByteSlice() bool
- func (c *Checker) IsChar() bool
- func (c *Checker) IsCollection() bool
- func (c *Checker) IsElement() bool
- func (c *Checker) IsFloat() bool
- func (c *Checker) IsFloatMap() bool
- func (c *Checker) IsFloatSet() bool
- func (c *Checker) IsFloatSlice() bool
- func (c *Checker) IsGenericMap() bool
- func (c *Checker) IsGenericSet() bool
- func (c *Checker) IsGenericSlice() bool
- func (c *Checker) IsInt() bool
- func (c *Checker) IsIntMap() bool
- func (c *Checker) IsIntSet() bool
- func (c *Checker) IsIntSlice() bool
- func (c *Checker) IsInterface() bool
- func (c *Checker) IsInvalid() bool
- func (c *Checker) IsMap() bool
- func (c *Checker) IsNil() bool
- func (c *Checker) IsNumber() bool
- func (c *Checker) IsPointer() bool
- func (c *Checker) IsRune() bool
- func (c *Checker) IsRuneMap() bool
- func (c *Checker) IsRuneSet() bool
- func (c *Checker) IsRuneSlice() bool
- func (c *Checker) IsSet() bool
- func (c *Checker) IsSlice() bool
- func (c *Checker) IsString() bool
- func (c *Checker) IsStringMap() bool
- func (c *Checker) IsStringSet() bool
- func (c *Checker) IsStringSlice() bool
- func (c *Checker) IsStruct() bool
- func (c *Checker) IsUint() bool
- func (c *Checker) IsUintMap() bool
- func (c *Checker) IsUintSet() bool
- func (c *Checker) IsUintSlice() bool
- func (c *Checker) IsZero() bool
- func (c *Checker) Kind() reflect.Kind
- func (c *Checker) KindClass() Classes
- func (c *Checker) MapClass() Classes
- func (c *Checker) SetClass() Classes
- func (c *Checker) SliceClass() Classes
- func (c *Checker) Type() reflect.Type
- func (c *Checker) Value() reflect.Value
- type Class
- type Classes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clone ¶
func Clone(e interface{}, deep ...bool) interface{}
Clone retourne une copie de l’élément fournit en paramètre. Si deep est fourni et vaut true, le clonage s’effectue récursivement.
func Convert ¶
Convert convertit la valeur du paramètre source vers le paramètre destination et retourne true si l’opération s’est effectuée avec succès. La destination doit être un pointeur, afin de pouvoir modifier sa valeur. Si le paramètre optionnel safe est fourni et vaut true, la destination n’est modifiée que si son type est équivalent à celui de la source (par exemple int vers int64, mais pas int vers string).
func IsBoolSlice ¶
func IsBoolSlice(e interface{}) bool
func IsByteSlice ¶
func IsByteSlice(e interface{}) bool
func IsCollection ¶
func IsCollection(e interface{}) bool
func IsFloatMap ¶
func IsFloatMap(e interface{}) bool
func IsFloatSet ¶
func IsFloatSet(e interface{}) bool
func IsFloatSlice ¶
func IsFloatSlice(e interface{}) bool
func IsGenericMap ¶
func IsGenericMap(e interface{}) bool
func IsGenericSet ¶
func IsGenericSet(e interface{}) bool
func IsGenericSlice ¶
func IsGenericSlice(e interface{}) bool
func IsIntSlice ¶
func IsIntSlice(e interface{}) bool
func IsInterface ¶
func IsInterface(e interface{}) bool
func IsRuneSlice ¶
func IsRuneSlice(e interface{}) bool
func IsStringMap ¶
func IsStringMap(e interface{}) bool
func IsStringSet ¶
func IsStringSet(e interface{}) bool
func IsStringSlice ¶
func IsStringSlice(e interface{}) bool
func IsUintSlice ¶
func IsUintSlice(e interface{}) bool
func PointerOf ¶
func PointerOf(e interface{}) interface{}
PointerOf retourne un pointeur vers une variable ayant la même valeur que le paramètre d’entrée.
func SetZero ¶
func SetZero(dst interface{}) bool
SetZero réinitialise la variable pointée par le paramètre d’entrée à sa valeur initiale
func ToBoolSlice ¶ added in v1.0.2
func ToByteSlice ¶ added in v1.0.2
func ToFloatMap ¶ added in v1.0.2
func ToFloatSet ¶ added in v1.0.2
func ToFloatSlice ¶ added in v1.0.2
func ToIntSlice ¶ added in v1.0.2
func ToInterface ¶
func ToRuneSlice ¶ added in v1.0.2
func ToStringMap ¶ added in v1.0.2
func ToStringSet ¶ added in v1.0.2
func ToStringSlice ¶ added in v1.0.2
func ToUintSlice ¶ added in v1.0.2
Types ¶
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
Checker est une structure permettant d’analyser finement les propriétés d’une variable en recherchant les classes auxquelles elle appartient.
func NewChecker ¶
func NewChecker(e interface{}) *Checker
NewChecker retourne un checker pour analyser le paramètre fourni.
func (*Checker) AllClasses ¶
AllClasses retournes toutes les classes d’appartenance de la valeur : - Type général/sur-ensemble, - Sous-ensemble éventuel dans le cas des collections, - Classes d’état (Nil et Zero).
func (*Checker) IsBoolSlice ¶
func (*Checker) IsByteSlice ¶
func (*Checker) IsCollection ¶
func (*Checker) IsFloatMap ¶
func (*Checker) IsFloatSet ¶
func (*Checker) IsFloatSlice ¶
func (*Checker) IsGenericMap ¶
func (*Checker) IsGenericSet ¶
func (*Checker) IsGenericSlice ¶
func (*Checker) IsIntSlice ¶
func (*Checker) IsInterface ¶
func (*Checker) IsNil ¶
IsNil est équivalent à la méthode IsZero de reflect.Value à la différence qu’aucun panic n’est généré en cas de valeur non nilable.
func (*Checker) IsRuneSlice ¶
func (*Checker) IsStringMap ¶
func (*Checker) IsStringSet ¶
func (*Checker) IsStringSlice ¶
func (*Checker) IsUintSlice ¶
func (*Checker) IsZero ¶
IsZero est équivalent à la méthode IsZero de reflect.Value à la différence qu’aucun panic n’est généré en cas de valeur de type reflect.Invalid
func (*Checker) SliceClass ¶
SliceClass retourne la sous-classe d’un élément de type Slice
type Class ¶
type Class uint
Class permet de classifier les types de données. On y retrouve : - Les classes standard implémentées dans reflect: Ptr, Struct, String, etc. - Des sur-ensembles de classes: Element, Number, Collection, etc. - Des sous-emsembles de classes (nécessitant d’analyser le type plus en profondeur): [*]Slice, [*]Map et [*]Set - Des classes décrivant l’état de la valeur de la donnée : Zero et Nil
À noter que certains types de données reflect ne sont pas géré par converter: Chan, Func, etc. Par ailleurs, la terminologie pour les type de nombres est quelque peut différente par rapport à reflect : - Int regroupe tous les type d’entiers (int, int8, int16, int32, int64) - Float regroupe tous les nombres à virgule flottante (float32, float64) - Contrairement à reflect, une distinction est faite entre les entiers purs et les entiers décrivant des caractères (rune et byte)
Concernant les variables de type map[typeKey]typeValue, seules sont supportées : - map[string]elementType (regroupées sous la classe Map) - map[elementType]bool (regroupées sous la classe Set) Tous les autres types de map sont rattachés uniquement à la classe Collection.
const ( Invalid Class = iota Zero Nil Ptr Struct Interface Element Number Char Collection Slice Map Set Bool Int Uint Float Rune Byte String GenericSlice BoolSlice IntSlice UintSlice FloatSlice RuneSlice ByteSlice StringSlice GenericMap BoolMap IntMap UintMap FloatMap RuneMap ByteMap StringMap GenericSet BoolSet IntSet UintSet FloatSet RuneSet ByteSet StringSet )