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 any, fieldName string) (any, bool)
- func GetStructureField(field reflect.Value) any
- func GetUnexportedStructureField(structure any, fieldName string) any
- func InheritsFrom(object any, parentType reflect.Type) bool
- func IsEmpty(value any) bool
- func SetStructField(structure any, fieldName string, value any) error
- func SetStructureField(field reflect.Value, value any)
- func SetUnexportedStructureField(structure any, fieldName string, value any)
- func ToStructPtr(obj reflect.Value) (val any, 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 empty, the field exists and is set.
func GetStructureField ¶
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
IsEmpty checks whether a value is empty i.e. "", nil, 0, [], {}, false, etc. For Strings, a string is considered empty if it is "" or if it only contains whitespaces
func SetStructField ¶
SetStructField attempts to set a field of a structure to the given value 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 ¶
Types ¶
This section is empty.