From 447c40aebded145778ffb7e00d3e0211d8c30047 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Sat, 10 Nov 2012 13:41:33 -0500 Subject: [PATCH] TRIVIAL go fmt --- .../buffered-channels/main.go | 38 ++--- .../exercise-rot13-reader/main.go | 160 +++++++++--------- 2 files changed, 99 insertions(+), 99 deletions(-) diff --git a/gotime/src/meatballhat.com/gotour-artifacts/buffered-channels/main.go b/gotime/src/meatballhat.com/gotour-artifacts/buffered-channels/main.go index 9873435..f5294da 100644 --- a/gotime/src/meatballhat.com/gotour-artifacts/buffered-channels/main.go +++ b/gotime/src/meatballhat.com/gotour-artifacts/buffered-channels/main.go @@ -1,29 +1,29 @@ package main import ( - "fmt" - "time" + "fmt" + "time" ) func main() { - c := make(chan int, 2) - q := make(chan bool) + c := make(chan int, 2) + q := make(chan bool) - go func(c chan int) { - for i := range c { - fmt.Println("\t", i, "<- popped") - time.Sleep(300 * time.Millisecond) - } - }(c) + go func(c chan int) { + for i := range c { + fmt.Println("\t", i, "<- popped") + time.Sleep(300 * time.Millisecond) + } + }(c) - go func(c chan int) { - i := 0 - for { - c <- i - fmt.Println("pushed ->", i) - i += 1 - } - }(c) + go func(c chan int) { + i := 0 + for { + c <- i + fmt.Println("pushed ->", i) + i += 1 + } + }(c) - <-q + <-q } diff --git a/gotime/src/meatballhat.com/gotour-artifacts/exercise-rot13-reader/main.go b/gotime/src/meatballhat.com/gotour-artifacts/exercise-rot13-reader/main.go index 0e477a1..9ec46c7 100644 --- a/gotime/src/meatballhat.com/gotour-artifacts/exercise-rot13-reader/main.go +++ b/gotime/src/meatballhat.com/gotour-artifacts/exercise-rot13-reader/main.go @@ -1,97 +1,97 @@ package main import ( - "fmt" - "io" - "os" - "strings" + "fmt" + "io" + "os" + "strings" ) var lookupTable = map[byte]byte{ - 'A': 'N', - 'B': 'O', - 'C': 'P', - 'D': 'Q', - 'E': 'R', - 'F': 'S', - 'G': 'T', - 'H': 'U', - 'I': 'V', - 'J': 'W', - 'K': 'X', - 'L': 'Y', - 'M': 'Z', - 'N': 'A', - 'O': 'B', - 'P': 'C', - 'Q': 'D', - 'R': 'E', - 'S': 'F', - 'T': 'G', - 'U': 'H', - 'V': 'I', - 'W': 'J', - 'X': 'K', - 'Y': 'L', - 'Z': 'M', - 'a': 'n', - 'b': 'o', - 'c': 'p', - 'd': 'q', - 'e': 'r', - 'f': 's', - 'g': 't', - 'h': 'u', - 'i': 'v', - 'j': 'w', - 'k': 'x', - 'l': 'y', - 'm': 'z', - 'n': 'a', - 'o': 'b', - 'p': 'c', - 'q': 'd', - 'r': 'e', - 's': 'f', - 't': 'g', - 'u': 'h', - 'v': 'i', - 'w': 'j', - 'x': 'k', - 'y': 'l', - 'z': 'm', + 'A': 'N', + 'B': 'O', + 'C': 'P', + 'D': 'Q', + 'E': 'R', + 'F': 'S', + 'G': 'T', + 'H': 'U', + 'I': 'V', + 'J': 'W', + 'K': 'X', + 'L': 'Y', + 'M': 'Z', + 'N': 'A', + 'O': 'B', + 'P': 'C', + 'Q': 'D', + 'R': 'E', + 'S': 'F', + 'T': 'G', + 'U': 'H', + 'V': 'I', + 'W': 'J', + 'X': 'K', + 'Y': 'L', + 'Z': 'M', + 'a': 'n', + 'b': 'o', + 'c': 'p', + 'd': 'q', + 'e': 'r', + 'f': 's', + 'g': 't', + 'h': 'u', + 'i': 'v', + 'j': 'w', + 'k': 'x', + 'l': 'y', + 'm': 'z', + 'n': 'a', + 'o': 'b', + 'p': 'c', + 'q': 'd', + 'r': 'e', + 's': 'f', + 't': 'g', + 'u': 'h', + 'v': 'i', + 'w': 'j', + 'x': 'k', + 'y': 'l', + 'z': 'm', } type rot13Reader struct { - reader io.Reader + reader io.Reader } func (rot *rot13Reader) Read(p []byte) (i int, err error) { - if len(p) == 0 { - return 0, nil - } - buf := make([]byte, len(p)) - i, err = rot.reader.Read(buf) + if len(p) == 0 { + return 0, nil + } + buf := make([]byte, len(p)) + i, err = rot.reader.Read(buf) - var ( - b, c byte - found bool - ) - for i := range buf { - b = buf[i] - c, found = lookupTable[b] - if found { - p[i] = c - } else { - p[i] = b - } - } - return + var ( + b, c byte + found bool + ) + for i := range buf { + b = buf[i] + c, found = lookupTable[b] + if found { + p[i] = c + } else { + p[i] = b + } + } + return } func main() { - s := strings.NewReader("Lbh penpxrq gur pbqr!") - r := rot13Reader{s} - io.Copy(os.Stdout, &r) - fmt.Println("") + s := strings.NewReader("Lbh penpxrq gur pbqr!") + r := rot13Reader{s} + io.Copy(os.Stdout, &r) + fmt.Println("") }