Documentation
¶
Overview ¶
Package deepset provides functionality to set a value of a given type on a value of any time that is or contains a value of the same type.
Package deepset provides functionality to set the an input object's value directly, or set it on one of the object's struct fields, based on the type of the value being set.
Example (Set) ¶
package main import ( "fmt" "github.com/splunk/go-splunk-client/pkg/deepset" ) type Namespace struct { User string App string } type ID struct { Title string Namespace Namespace } type View struct { ID ID Content string } func main() { myView := View{} // returned error ignored here _ = deepset.Set(&myView, Namespace{User: "admin", App: "search"}) fmt.Printf("ID User: %s, App: %s", myView.ID.Namespace.User, myView.ID.Namespace.App) }
Output: ID User: admin, App: search
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Set ¶
func Set(dest interface{}, value interface{}) error
Set attempts to set the given value on dest.
If dest and value are of the same underlying type, dest will be set directly.
If dest is a struct, and exactly one of its fields are of the same underlying type as value, that field will be set to value.
Any dest field that is a struct will be followed recursively.
If multiple struct fields at any given level match the value type, an error is returned.
Types ¶
This section is empty.