Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Zero ¶
func Zero(inputIntf interface{}) error
Zero allocates an input structure such that all pointer fields are fully allocated, i.e. rather than having a nil value, the pointer contains a pointer to an initialized value, e.g. an *int field will be a pointer to 0 instead of a nil pointer.
Zero does not allocate private fields.
Example ¶
ExampleZero is a simple example to demonstrate the how Zero() performs allocation
type SimplePtrStruct struct {
PtrField *int
}
ptrStruct := SimplePtrStruct{}
fmt.Printf("pre allocate.Zero: %v\n", ptrStruct.PtrField)
Zero(&ptrStruct)
fmt.Printf("post allocate.Zero: %v\n", *ptrStruct.PtrField)
Output: pre allocate.Zero: <nil> post allocate.Zero: 0
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.