Golang ProgramsGolang Programs

Passing multiple string arguments to a variadic function

The parameter s accepts an infinite number of arguments. The tree-dotted ellipsis tells the compiler that this string will accept, from zero to multiple values.
package main

import "fmt"

func main() {
	variadicExample("red", "blue")
	variadicExample("red", "blue", "green")
	variadicExample("red", "blue", "green", "yellow")

func variadicExample(s ...string) {
C:\golang\example>go run test1.go
[red blue]
[red blue green]
[red blue green yellow]

In the above example, we have called the function with single and multiple arguments; and without passing any arguments.