How To Initialize a Go Struct With a Lot of Pointers

I’ve been working on a project using Go Swagger. It can generate your models as golang structs for you. However, if you have a lot of nullable fields, you will end up with structs with a lot of pointer attributes.

If want to conviniently initialize that struct with zero pointers of all the pointer fields, simply use the new(..) keyword instead of declaring variables and then assigining their references to the pointers

Output