mirror of
https://github.com/teivah/100-go-mistakes.git
synced 2026-06-20 16:45:56 +08:00
27 lines
340 B
Go
27 lines
340 B
Go
package main
|
|
|
|
type Foo struct {
|
|
a int64
|
|
b int64
|
|
}
|
|
|
|
func sumFoo(foos []Foo) int64 {
|
|
var total int64
|
|
for i := 0; i < len(foos); i++ {
|
|
total += foos[i].a
|
|
}
|
|
return total
|
|
}
|
|
|
|
type Bar struct {
|
|
a []int64
|
|
b []int64
|
|
}
|
|
|
|
func sumBar(bar Bar) int64 {
|
|
var total int64
|
|
for i := 0; i < len(bar.a); i++ {
|
|
total += bar.a[i]
|
|
}
|
|
return total
|
|
}
|