I make global declaration of a value.
var {
b = make([]string,10) //way 1
a = []string{} //way 2
}
Both ways work. Can someone make detailed explanation of the difference between them?
The expression make([]string,10)
returns a slice with length and capacity of 10. The expression []string{}
returns a slice with length and capacity of 0.