In order to don\'t repeat my self over and over I wanted to create a function that handles running some commands.
func runCommand(name string, arg ...string
You expand the []string
with another ...
cmd := exec.Command(name, arg...)
From the language spec on Passing arguments to ... parameters
If the final argument is assignable to a slice type
[]T
, it may be passed unchanged as the value for a...T
parameter if the argument is followed by...
. In this case no new slice is created.Given the slice s and call
s := []string{"James", "Jasmine"} Greeting("goodbye:", s...)
within Greeting,
who
will have the same value ass
with the same underlying array.