Pass a slice to a variadic function

yourbasic.org/golang

You can pass a slice s directly to a variadic funtion using the s... notation.

func main() {
    primes := []int{2, 3, 5, 7}
    fmt.Println(Sum(primes...)) // 17
}   

func Sum(nums ...int) int {
    res := 0
    for _, n := range nums {
        res += n
    }
    return res
}

Further reading

Slices in a nutshell