In Go, is there a notable difference between the following two segments of code:
v := &Vector{}
as opposed to
v := new(
According to Effective Go, new()
is a function that allocates memory, and zeros it out; that is every field (and the entire piece of memory for the structure) will be set to 0
s. If you design your structures so that when they're created all fields should equal zero, than it's fine and recommended to use it. If, however, you need more control over what initial values are to be used, then the more conventional method should be used.
In the specific case you mention the difference is irrelevant, but it should be noted elsewhere.
I hope this helps! :)