I want to unpack string array and pass to path.Join
package main
import (
"fmt"
"path"
)
func main() {
p := []string{"a", "b", "c"}
fmt.Println(path.Join(p...))
}
Output of this code is:
a/b/c
But if I pass arguments like:
package main
import (
"fmt"
"path"
)
func main() {
p := []string{"a", "b", "c"}
fmt.Println(path.Join("d", p...))
}
It doesn't work.
tmp/sandbox299218161/main.go:10: too many arguments in call to path.Join
have (string, []string...)
want (...string)
I think I have misunderstanding on unpacking, any suggestions?