I have the following Golang main
function where another variadic function variadicFunc
is called to which I need to pass parameters of different datatypes. The code is as follows.
package main
import "fmt"
func main() {
variadicFunc("hello", "Change", "the ", "World using Golang", 1, 2, 3, 4)
}
func variadicFunc(messages ...string) {
for _, i := range messages {
fmt.Println(i)
}
}
When running the program following error is thrown.
Cannot use 1(type int) as type string in argument to variadicFunc