Documentation ¶
Overview ¶
* Copyright (C) 2020-2022 Arm Limited or its affiliates and Contributors. All rights reserved. * SPDX-License-Identifier: Apache-2.0
Index ¶
- func GetStructField(structure interface{}, fieldName string) (interface{}, bool)
- func GetStructureField(field reflect.Value) interface{}
- func GetUnexportedStructureField(structure interface{}, fieldName string) interface{}
- func InheritsFrom(object interface{}, parentType reflect.Type) bool
- func IsEmpty(value interface{}) bool
- func SetStructField(structure interface{}, fieldName string, value interface{}) error
- func SetStructureField(field reflect.Value, value interface{})
- func SetUnexportedStructureField(structure interface{}, fieldName string, value interface{})
- func ToStructPtr(obj reflect.Value) (val interface{}, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetStructField ¶
GetStructField checks if the given structure has a given field. The structure should be passed by reference. It returns an interface and a boolean, the field's content and a boolean denoting whether or not the field exists. If the boolean is false then there is no such field on the structure. If the boolean is true but the interface stores "" then the field exists but is not set. If the boolean is true and the interface is not emtpy, the field exists and is set.
func GetStructureField ¶
func GetUnexportedStructureField ¶
func GetUnexportedStructureField(structure interface{}, fieldName string) interface{}
func InheritsFrom ¶
InheritsFrom uses reflection to find if a struct "inherits" from a certain type. In other words it checks whether the struct embeds a struct of that type.
func IsEmpty ¶ added in v1.4.2
func IsEmpty(value interface{}) bool
IsEmpty checks whether a value is empty i.e. "", nil, 0, [], {}, false, etc.
func SetStructField ¶
SetStructField attempts to set a field of a structure to the given vaule It returns nil or an error, in case the field doesn't exist on the structure or the value and the field have different types
func SetStructureField ¶
func SetUnexportedStructureField ¶
func SetUnexportedStructureField(structure interface{}, fieldName string, value interface{})
func ToStructPtr ¶ added in v1.8.0
ToStructPtr returns an instance of the pointer (interface) to the object obj.
Types ¶
This section is empty.