what should be used New() or var in go? -
how object should created struct?
object := new(struct)
or
var object struct
i not understatnd when use what? , if both same 1 should prefered?
when need pointer object use new or composite literal else use var.
use var whenever possible more allocated in stack , memory freed scope ends. case of new memory gets allocated in heap , need garbage collected.
Comments
Post a Comment