Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssignIfCompatible ¶
func AssignIfCompatible(dst, src interface{}) error
AssignIfCompatible is a convenience function to safely assign arbitrary values. dst must be a pointer to an empty interface, or it must be a pointer to a compatible variable type that can hold src.
func AssignOptionalField ¶ added in v1.0.2
func AssignOptionalField(dst, src interface{}) error
AssignField is a convenience function to assign a value to an optional struct field. In Go, an optional struct field is usually denoted by a pointer to T instead of T:
type Object struct { Optional *T }
This gets a bit cumbersome when you want to assign literals or you do not want to worry about taking the address of a variable.
Object.Optional = &"foo" // doesn't compile!
Instead you can use this function to do it in one line:
blackmagic.AssignOptionalField(&Object.Optionl, "foo")
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.