Variadic functions accept any number of arguments. Use ... before the type to make the last parameter variadic:
func sum(nums ...int) int {
total := 0
for _, n := range nums {
total += n
}
return total
}
Call it with any number of integers: sum(, , ) or sum(, , , , ). Inside the function, nums is a slice containing all the arguments passed.