Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save shockalotti/36790db099fc318fce25 to your computer and use it in GitHub Desktop.
Save shockalotti/36790db099fc318fce25 to your computer and use it in GitHub Desktop.
Go Golang - variadic function (with unknown number of arguments)
package main
import "fmt"
func add(args ...int) int {
total :=0
for _, v := range args {
total += v
}
return total
}
func main() {
fmt.Println(add(1,2,3))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment