3 ms·
That would be my preference too. Great readability, and most users would eventually try this out even before searching for the right way (I have tried it). I t
by cassianoleal 6y ago
That would be my preference too. Great readability, and most users would eventually try this out even before searching for the right way (I have tried it).
I tend to not declare variables when the pointer is used deep into a struct because I find the back-and-forth in the editor to be bad. I usually resort to a pointer to an inline anonymous function, e.g.:
a := SomeStruct{
Field: func() *int64 { x := int64(13); return &x }(),
}
It's ugly and verbose but after seeing it 2 or 3 times you immediately know what it's about the next time.