mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 01:21:38 +08:00
fix: coding style and file format for all example.
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
type IntVector []int
|
||||
|
||||
func (v IntVector) Sum() (s int) {
|
||||
for _, x := range v {
|
||||
s += x
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println(IntVector{1, 2, 3}.Sum()) // Output: 6
|
||||
}
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
type IntVector []int
|
||||
|
||||
func (v IntVector) Sum() (s int) {
|
||||
for _, x := range v {
|
||||
s += x
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println(IntVector{1, 2, 3}.Sum()) // Output: 6
|
||||
}
|
||||
|
Reference in New Issue
Block a user