go-examples/echorot13/main.go
2017-07-09 17:29:52 +02:00

34 lines
439 B
Go

package main
import (
"bufio"
"io"
"net"
"github.com/wayneashleyberry/rot13"
)
func main() {
ln, err := net.Listen("tcp", ":9000")
if err != nil {
panic(err)
}
defer ln.Close()
for {
conn, err := ln.Accept()
if err != nil {
panic(err)
}
go func() {
scanner := bufio.NewScanner(conn)
for scanner.Scan() {
str := scanner.Text()
io.WriteString(conn, rot13.Encode(str))
}
conn.Close()
}()
}
}