[]string is a string array
Technically, this is a fragment that references a base array
and we also use ...string as a parameter.
What is the difference?
As for the structure, nothing special. The data type obtained in both syntaxes is the same.
Parameter syntax ... creates a variable parameter. It will take zero or more string arguments and refer to them as a fragment.
As for calling f , you can pass a fragment of the string to a variable parameter with the following syntax:
func f(args ...string) { fmt.Println(len(args)) } args := []string{"a", "b"} f(args...)
This syntax is available either for a slice constructed using literal syntax, or for a slice representing a parameter with variable parameters (since there really are no differences between them).
http://play.golang.org/p/QWmzgIWpF8
I Hate Lazy Oct. 16 2018-12-12T00: 00Z
source share