This is a creation in Article, where the information may have evolved or changed.
1. For arrays: Indicates the same length as the number of elements.
The length of the array in Golang is part of the type, different lengths, different types.
2. For parameters: used for formal parameter representation of variable parameters. Used for arguments to represent direct delivery. See the official documentation for specific explanation parameters:
When passing mutable parameters:
(1) If the argument is not followed by ..., the slice is created at the bottom with the same parameter type and then passed after the argument is assigned a value.
(2) If the argument is followed by ..., the slice is not created at the bottom with the same parameter type, but the argument is passed directly to the parameter.
/ref/spec#passing_arguments_to_..._parameters
Passing arguments to ... parameters
If f is variadic with a final parameter p of type ...T , then within the type of was f equivalent to p type []T. If f is invoked with no actual arguments p for, the value of passed to is p nil . Otherwise, the value passed is a new slice of type with []T a new underlying array whose successive elements are the AC tual arguments, which all must is assignable to T . The length and capacity of the slice are therefore the number of arguments bound to and could differ for each call p sit E.
Given the function and calls
Func greeting (prefix string, who ... string)
Greeting ("Nobody")
Greeting ("Hello:", "Joe", "Anna", "Eileen")
Within Greeting , would has who the value nil in the first call, and the []string{"Joe", "Anna", "Eileen"} second.
If The final argument is assignable to a slice type []T , it could be passed unchanged as the value for a ...T parameter I f The argument is followed by ... . In this case no new slice is created.
Given the slice and call s
s: = []string{"James", "Jasmine"}greeting ("Goodbye:", S ...)
Within Greeting , would has the same value as with the who s same underlying array.