From 736d61e82c259cb504e8de11b5ca7b6c90c2c238 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Mon, 5 Nov 2012 21:00:35 -0500 Subject: [PATCH] TRIVIAL go fmt --- .../gotour-artifacts/channels/main.go | 40 +++++++++---------- .../exercise-fibonacci-closure/main.go | 24 +++++------ .../exercise-http-handlers/main.go | 28 ++++++------- .../gotour-artifacts/exercise-maps/main.go | 18 ++++----- .../gotour-artifacts/exercise-slices/main.go | 20 +++++----- .../gotour-artifacts/exercise-sqrt/main.go | 28 ++++++------- .../gotour-artifacts/goroutines/main.go | 16 ++++---- .../gotour-artifacts/hello-web/main.go | 14 +++---- .../gotour-artifacts/maps/main.go | 12 +++--- .../gotour-artifacts/ranges/main.go | 14 +++---- 10 files changed, 107 insertions(+), 107 deletions(-) diff --git a/gotime/src/meatballhat.com/gotour-artifacts/channels/main.go b/gotime/src/meatballhat.com/gotour-artifacts/channels/main.go index 0b9722a..cd25408 100644 --- a/gotime/src/meatballhat.com/gotour-artifacts/channels/main.go +++ b/gotime/src/meatballhat.com/gotour-artifacts/channels/main.go @@ -1,31 +1,31 @@ package main import ( - "fmt" - "time" - "math" + "fmt" + "math" + "time" ) func sum(a []int, c chan int) { - sum := 0 - for _, v := range a { - sum += v - } - to_sleep := time.Duration(100 * math.Abs(float64(sum))) * time.Millisecond - fmt.Printf("Sleeping %s...\n", to_sleep) - time.Sleep(to_sleep) - c <- sum + sum := 0 + for _, v := range a { + sum += v + } + to_sleep := time.Duration(100*math.Abs(float64(sum))) * time.Millisecond + fmt.Printf("Sleeping %s...\n", to_sleep) + time.Sleep(to_sleep) + c <- sum } func main() { - a := []int{7, 2, 8, -9, 4, 0} + a := []int{7, 2, 8, -9, 4, 0} - c := make(chan int) - go sum(a[:len(a)/2], c) - go sum(a[len(a)/2:], c) - x := <-c - fmt.Printf("x = %d\n", x) - y := <-c - fmt.Printf("y = %d\n", y) - fmt.Println(x, y, x + y) + c := make(chan int) + go sum(a[:len(a)/2], c) + go sum(a[len(a)/2:], c) + x := <-c + fmt.Printf("x = %d\n", x) + y := <-c + fmt.Printf("y = %d\n", y) + fmt.Println(x, y, x+y) } diff --git a/gotime/src/meatballhat.com/gotour-artifacts/exercise-fibonacci-closure/main.go b/gotime/src/meatballhat.com/gotour-artifacts/exercise-fibonacci-closure/main.go index 2ab954b..8981957 100644 --- a/gotime/src/meatballhat.com/gotour-artifacts/exercise-fibonacci-closure/main.go +++ b/gotime/src/meatballhat.com/gotour-artifacts/exercise-fibonacci-closure/main.go @@ -5,19 +5,19 @@ import "fmt" // fibonacci is a function that returns // a function that returns an int. func fibonacci() func() int { - prev := 0 - cur := 1 - return func() int { - old_cur := cur - cur = prev + cur - prev = old_cur - return cur - } + prev := 0 + cur := 1 + return func() int { + old_cur := cur + cur = prev + cur + prev = old_cur + return cur + } } func main() { - f := fibonacci() - for i := 0; i < 10; i++ { - fmt.Println(f()) - } + f := fibonacci() + for i := 0; i < 10; i++ { + fmt.Println(f()) + } } diff --git a/gotime/src/meatballhat.com/gotour-artifacts/exercise-http-handlers/main.go b/gotime/src/meatballhat.com/gotour-artifacts/exercise-http-handlers/main.go index e66cc29..fbfa512 100644 --- a/gotime/src/meatballhat.com/gotour-artifacts/exercise-http-handlers/main.go +++ b/gotime/src/meatballhat.com/gotour-artifacts/exercise-http-handlers/main.go @@ -1,32 +1,32 @@ package main import ( - "fmt" - "net/http" + "fmt" + "net/http" ) type String string type Struct struct { - Greeting string - Punct string - Who string + Greeting string + Punct string + Who string } func (s String) ServeHTTP( - w http.ResponseWriter, - r *http.Request) { - fmt.Fprintf(w, "%s\n", s) + w http.ResponseWriter, + r *http.Request) { + fmt.Fprintf(w, "%s\n", s) } func (s Struct) ServeHTTP( - w http.ResponseWriter, - r *http.Request) { - fmt.Fprintf(w, "%s%s %s", s.Greeting, s.Punct, s.Who) + w http.ResponseWriter, + r *http.Request) { + fmt.Fprintf(w, "%s%s %s", s.Greeting, s.Punct, s.Who) } func main() { - http.Handle("/string", String("I'm a frayed knot.")) - http.Handle("/struct", &Struct{"Hello", ":", "Gophers!"}) - http.ListenAndServe("localhost:4000", nil) + http.Handle("/string", String("I'm a frayed knot.")) + http.Handle("/struct", &Struct{"Hello", ":", "Gophers!"}) + http.ListenAndServe("localhost:4000", nil) } diff --git a/gotime/src/meatballhat.com/gotour-artifacts/exercise-maps/main.go b/gotime/src/meatballhat.com/gotour-artifacts/exercise-maps/main.go index 9d6f71a..eac7df1 100644 --- a/gotime/src/meatballhat.com/gotour-artifacts/exercise-maps/main.go +++ b/gotime/src/meatballhat.com/gotour-artifacts/exercise-maps/main.go @@ -1,19 +1,19 @@ package main import ( - "strings" - "code.google.com/p/go-tour/wc" + "code.google.com/p/go-tour/wc" + "strings" ) func WordCount(s string) map[string]int { - counts := make(map[string]int) - words := strings.Fields(s) - for _, word := range words { - counts[word]++ - } - return counts + counts := make(map[string]int) + words := strings.Fields(s) + for _, word := range words { + counts[word]++ + } + return counts } func main() { - wc.Test(WordCount) + wc.Test(WordCount) } diff --git a/gotime/src/meatballhat.com/gotour-artifacts/exercise-slices/main.go b/gotime/src/meatballhat.com/gotour-artifacts/exercise-slices/main.go index 111ef15..ab7d104 100644 --- a/gotime/src/meatballhat.com/gotour-artifacts/exercise-slices/main.go +++ b/gotime/src/meatballhat.com/gotour-artifacts/exercise-slices/main.go @@ -1,20 +1,20 @@ package main import ( - "code.google.com/p/go-tour/pic" + "code.google.com/p/go-tour/pic" ) func Pic(dx, dy int) [][]uint8 { - cols := make([][]uint8, dy) - for i := range cols { - cols[i] = make([]uint8, dx) - for j := range cols[i] { - cols[i][j] = uint8(j^i) - } - } - return cols + cols := make([][]uint8, dy) + for i := range cols { + cols[i] = make([]uint8, dx) + for j := range cols[i] { + cols[i][j] = uint8(j ^ i) + } + } + return cols } func main() { - pic.Show(Pic) + pic.Show(Pic) } diff --git a/gotime/src/meatballhat.com/gotour-artifacts/exercise-sqrt/main.go b/gotime/src/meatballhat.com/gotour-artifacts/exercise-sqrt/main.go index 806c350..8737b50 100644 --- a/gotime/src/meatballhat.com/gotour-artifacts/exercise-sqrt/main.go +++ b/gotime/src/meatballhat.com/gotour-artifacts/exercise-sqrt/main.go @@ -1,25 +1,25 @@ package main import ( - "fmt" - "math" + "fmt" + "math" ) // using Newton's method func Sqrt(x float64) float64 { - z := x - (x * 0.1) - for i := 0 ; i < 1000 ; i++ { - newZ := z - (((z * z) - x) / 2 * z) - diff := math.Abs(newZ) - math.Abs(z) - if math.Abs(diff) < 0.01 { - return newZ - } - z = newZ - } - return z + z := x - (x * 0.1) + for i := 0; i < 1000; i++ { + newZ := z - (((z * z) - x) / 2 * z) + diff := math.Abs(newZ) - math.Abs(z) + if math.Abs(diff) < 0.01 { + return newZ + } + z = newZ + } + return z } func main() { - fmt.Printf("stdlib -> %f\n", math.Sqrt(2)) - fmt.Printf("newton -> %f\n", Sqrt(2)) + fmt.Printf("stdlib -> %f\n", math.Sqrt(2)) + fmt.Printf("newton -> %f\n", Sqrt(2)) } diff --git a/gotime/src/meatballhat.com/gotour-artifacts/goroutines/main.go b/gotime/src/meatballhat.com/gotour-artifacts/goroutines/main.go index 84bf43c..0e7be4c 100644 --- a/gotime/src/meatballhat.com/gotour-artifacts/goroutines/main.go +++ b/gotime/src/meatballhat.com/gotour-artifacts/goroutines/main.go @@ -1,18 +1,18 @@ package main import ( - "fmt" - "time" + "fmt" + "time" ) func say(s string) { - for i := 0; i < 5; i++ { - time.Sleep(100 * time.Millisecond) - fmt.Println(s) - } + for i := 0; i < 5; i++ { + time.Sleep(100 * time.Millisecond) + fmt.Println(s) + } } func main() { - go say("world") - say("hello") + go say("world") + say("hello") } diff --git a/gotime/src/meatballhat.com/gotour-artifacts/hello-web/main.go b/gotime/src/meatballhat.com/gotour-artifacts/hello-web/main.go index e6856ae..91534ba 100644 --- a/gotime/src/meatballhat.com/gotour-artifacts/hello-web/main.go +++ b/gotime/src/meatballhat.com/gotour-artifacts/hello-web/main.go @@ -1,19 +1,19 @@ package main import ( - "fmt" - "net/http" + "fmt" + "net/http" ) type Hello struct{} func (h Hello) ServeHTTP( - w http.ResponseWriter, - r *http.Request) { - fmt.Fprint(w, "Hello!\n") + w http.ResponseWriter, + r *http.Request) { + fmt.Fprint(w, "Hello!\n") } func main() { - var h Hello - http.ListenAndServe("localhost:4000", h) + var h Hello + http.ListenAndServe("localhost:4000", h) } diff --git a/gotime/src/meatballhat.com/gotour-artifacts/maps/main.go b/gotime/src/meatballhat.com/gotour-artifacts/maps/main.go index 991285d..bd21dbd 100644 --- a/gotime/src/meatballhat.com/gotour-artifacts/maps/main.go +++ b/gotime/src/meatballhat.com/gotour-artifacts/maps/main.go @@ -4,15 +4,15 @@ package main import "fmt" type Vertex struct { - Lat, Long float64 + Lat, Long float64 } var m map[string]Vertex func main() { - m = make(map[string]Vertex) - m["Bell Labs"] = Vertex{ - 40.68433, 74.39967, - } - fmt.Println(m["Bell Labs"]) + m = make(map[string]Vertex) + m["Bell Labs"] = Vertex{ + 40.68433, 74.39967, + } + fmt.Println(m["Bell Labs"]) } diff --git a/gotime/src/meatballhat.com/gotour-artifacts/ranges/main.go b/gotime/src/meatballhat.com/gotour-artifacts/ranges/main.go index 9ae0a27..93041cf 100644 --- a/gotime/src/meatballhat.com/gotour-artifacts/ranges/main.go +++ b/gotime/src/meatballhat.com/gotour-artifacts/ranges/main.go @@ -3,11 +3,11 @@ package main import "fmt" func main() { - pow := make([]int, 10) - for i := range pow { - pow[i] = 1 << uint(i) - } - for _, value := range pow { - fmt.Printf("%d\n", value) - } + pow := make([]int, 10) + for i := range pow { + pow[i] = 1 << uint(i) + } + for _, value := range pow { + fmt.Printf("%d\n", value) + } }