Skip to content

Instantly share code, notes, and snippets.

@edvm
Created October 25, 2015 04:00
Show Gist options
  • Save edvm/a06937bac49ec2176fc0 to your computer and use it in GitHub Desktop.
Save edvm/a06937bac49ec2176fc0 to your computer and use it in GitHub Desktop.
package main
import "fmt"
func sum(slice *[]int) int {
total := 0
for _, val := range *slice {
total += val
}
return total
}
func main() {
ints := []int{1, 2, 3, 4, 5}
fmt.Println(ints)
fmt.Println(sum(&ints))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment