I want to pass in a list of strings as generic parameters in go, but not sure if its possible. I have workarounds but feel like I'm just not able to get syntax correct.
package main
import "fmt"
func Set(otherFields ...interface{}) {
fmt.Printf("%v", otherFields)
}
func main() {
a := []string {"Abc", "def", "ghi"}
Set(a) // incorrect behavior because a passed through as a list, rather than a bunch of parameters
// Set(a...) // compiler error: cannot use a (type []string) as type []interface {} in argument to Set
// Set([]interface{}(a)) // compiler error: cannot convert a (type []string) to type []interface {}
// This works but I want to do what was above.
b := []interface{} {"Abc", "def", "ghi"}
Set(b...)
}