This question already has an answer here:
- Why would I make() or new()? 7 answers
In Go, I read document and understand basic differences between make
and new
- new: return a pointer (*T) and zeros value it points to
- make: return type T
I read document and mostly example using array. I understand new
vs make
when creating array. But I don't understand differences when creating channel:
c1 := new(chan string)
c2 := make(chan string)
What is real differences except that c1 has type (chan*) and c2 has type chan.
Thanks
</div>