Use tabs as the canonical source indentation in git

Space conversion is done during generation only. Fixes #192
This commit is contained in:
Eli Bendersky
2019-06-01 06:04:32 -07:00
committed by Mark McGranaghan
parent 1699ad1c45
commit 7c160440be
152 changed files with 1929 additions and 1939 deletions

View File

@@ -8,35 +8,35 @@ import "math"
// Here's a basic interface for geometric shapes.
type geometry interface {
area() float64
perim() float64
area() float64
perim() float64
}
// For our example we'll implement this interface on
// `rect` and `circle` types.
type rect struct {
width, height float64
width, height float64
}
type circle struct {
radius float64
radius float64
}
// To implement an interface in Go, we just need to
// implement all the methods in the interface. Here we
// implement `geometry` on `rect`s.
func (r rect) area() float64 {
return r.width * r.height
return r.width * r.height
}
func (r rect) perim() float64 {
return 2*r.width + 2*r.height
return 2*r.width + 2*r.height
}
// The implementation for `circle`s.
func (c circle) area() float64 {
return math.Pi * c.radius * c.radius
return math.Pi * c.radius * c.radius
}
func (c circle) perim() float64 {
return 2 * math.Pi * c.radius
return 2 * math.Pi * c.radius
}
// If a variable has an interface type, then we can call
@@ -44,19 +44,19 @@ func (c circle) perim() float64 {
// generic `measure` function taking advantage of this
// to work on any `geometry`.
func measure(g geometry) {
fmt.Println(g)
fmt.Println(g.area())
fmt.Println(g.perim())
fmt.Println(g)
fmt.Println(g.area())
fmt.Println(g.perim())
}
func main() {
r := rect{width: 3, height: 4}
c := circle{radius: 5}
r := rect{width: 3, height: 4}
c := circle{radius: 5}
// The `circle` and `rect` struct types both
// implement the `geometry` interface so we can use
// instances of
// these structs as arguments to `measure`.
measure(r)
measure(c)
// The `circle` and `rect` struct types both
// implement the `geometry` interface so we can use
// instances of
// these structs as arguments to `measure`.
measure(r)
measure(c)
}

View File

@@ -1,2 +1,2 @@
3547b935d1e0322c0fb696726c27cae53a275e0a
313UebA3rD
0EwsqIn3TTi