mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 04:48:29 +08:00
fix: coding style and file format for all example.
This commit is contained in:
@@ -1,24 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
)
|
||||
|
||||
type Point struct {
|
||||
x, y float64
|
||||
}
|
||||
|
||||
func (p *Point) Abs() float64 {
|
||||
return math.Sqrt(p.x*p.x + p.y*p.y)
|
||||
}
|
||||
|
||||
type NamedPoint struct {
|
||||
Point
|
||||
name string
|
||||
}
|
||||
|
||||
func main() {
|
||||
n := &NamedPoint{Point{3, 4}, "Pythagoras"}
|
||||
fmt.Println(n.Abs()) // prints 5
|
||||
}
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
)
|
||||
|
||||
type Point struct {
|
||||
x, y float64
|
||||
}
|
||||
|
||||
func (p *Point) Abs() float64 {
|
||||
return math.Sqrt(p.x*p.x + p.y*p.y)
|
||||
}
|
||||
|
||||
type NamedPoint struct {
|
||||
Point
|
||||
name string
|
||||
}
|
||||
|
||||
func main() {
|
||||
n := &NamedPoint{Point{3, 4}, "Pythagoras"}
|
||||
fmt.Println(n.Abs()) // prints 5
|
||||
}
|
||||
|
Reference in New Issue
Block a user