I think you can also do the second in Go with named returns, e.g.
func sum(nums []int) (result int) {
for _, n := range nums {
result += n
}
}
No clue if it's an idiomatic usage, and named returns always felt a little too magic for me.