TRIVIAL go fmt

This commit is contained in:
Dan Buch 2012-11-10 13:41:33 -05:00
parent ab9db7837d
commit 447c40aebd
2 changed files with 99 additions and 99 deletions

View File

@ -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
}

View File

@ -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("")
}