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

Popular posts from this blog

Upgrade php version of xampp not success -

amazon web services - S3 and apache mod_proxy with basic authentication -

powershell - This solution contains one or more assemblies targeted for the global assembly cache -