allocate
allocate copied to clipboard
Easily initialize golang structs with pointers to zero'd values instead of nil values
Protobuf now has 3 unexported fields ```golang type MyPbStruct struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields MyInt int32 `protobuf:"varint,1,opt,name=my_int,json=friendRuid,proto3" json:"my_int,omitempty"` } ``` When trying to set this struct zero...
```go func main() { // topStruct is a pointer to TopLevelStruct topStruct := new(TopLevelStruct) fmt.Printf("before using allocate.Zero: %v\n", topStruct) // try to allocate.Zero a pointer to pointer // should be:...
A panic occurs when there is a circular reference to the structure code ```go func Test_xxx(t *testing.T) { type Node struct { ID int Next *Node } var node Node...