Skip to content
This repository has been archived by the owner on Mar 22, 2021. It is now read-only.

Commit

Permalink
add fabian
Browse files Browse the repository at this point in the history
  • Loading branch information
miekg committed Jul 20, 2012
1 parent 86fa47b commit d04514a
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 6 deletions.
5 changes: 4 additions & 1 deletion ex-communication/ex-finger.tex
Expand Up @@ -20,6 +20,9 @@
\end{Exercise} \end{Exercise}


\begin{Answer} \begin{Answer}
\begin{lbar}
This solution is from Fabian Becker.
\end{lbar}
\Question \Question
Supply code and it may get included here. \lstinputlisting[label=src:fingerd,caption=A finger daemon]{ex-communication/src/finger.go}
\end{Answer} \end{Answer}
7 changes: 5 additions & 2 deletions ex-communication/ex-quine.tex
Expand Up @@ -5,9 +5,12 @@
\end{Exercise} \end{Exercise}


\begin{Answer} \begin{Answer}
\begin{lbar}
This solution is from Russ Cox. It was posted to
the Go Nuts mailing list.
\end{lbar}
\Question \Question
The following Quine is from Russ Cox: \begin{lstlisting}[caption=A Go quine]
\begin{lstlisting}
/* Go quine */ /* Go quine */
package main package main
import "fmt" import "fmt"
Expand Down
53 changes: 53 additions & 0 deletions ex-communication/src/finger.go
@@ -0,0 +1,53 @@
package main

import (
"bufio"
"io/ioutil"
"errors"
"net"
"os/user"
"flag"
"strconv"
)

var port *int = flag.Int("port", 79, "Port to listen on")

func main() {
flag.Parse()
ln, err := net.Listen("tcp", ":"+ strconv.Itoa(*port))
if err != nil {
panic(err)
}
for {
conn, err := ln.Accept()
if err != nil {
continue
}
go handleConnection(conn)
}
}

func handleConnection(conn net.Conn) {
defer conn.Close()
reader := bufio.NewReader(conn)
usr, _, _ := reader.ReadLine()

info, err := getUserInfo(string(usr))
if err != nil {
conn.Write([]byte(err.Error()))
} else {
conn.Write(info)
}
}

func getUserInfo(usr string) ([]byte, error) {
u, e := user.Lookup(usr)
if e != nil {
return nil, e
}
data, err := ioutil.ReadFile(u.HomeDir + ".plan")
if err != nil {
return data, errors.New("User doesn't have a .plan file!\n")
}
return data, nil
}
1 change: 1 addition & 0 deletions go-contributors.tex
Expand Up @@ -9,6 +9,7 @@
\emph{Cecil New}, \emph{Cecil New},
\emph{Damian Gryski}, \emph{Damian Gryski},
\emph{Dan Kortschak}, \emph{Dan Kortschak},
\emph{Fabian Becker},
\emph{Filip Zaludek}, \emph{Filip Zaludek},
\emph{Haiping Fan}, \emph{Haiping Fan},
\emph{Jaap Akkerhuis}, \emph{Jaap Akkerhuis},
Expand Down
6 changes: 3 additions & 3 deletions go.bib
Expand Up @@ -34,21 +34,21 @@ @misc{duck_typing
} }


@misc{bubblesort, @misc{bubblesort,
author = "Wikipedia", author = "{W}ikipedia",
howpublished = {\url{http://en.wikipedia.org/wiki/Bubble_sort}}, howpublished = {\url{http://en.wikipedia.org/wiki/Bubble_sort}},
title = "Bubble sort", title = "Bubble sort",
year = 2010 year = 2010
} }


@misc{go_nuts, @misc{go_nuts,
author = "{G}o Community", author = "{G}o Community",
title = "{G}o Nuts mailing list", title = "{G}o {N}uts mailing list",
howpublished = {\url{http://groups.google.com/group/golang-nuts}}, howpublished = {\url{http://groups.google.com/group/golang-nuts}},
year = 2010 year = 2010
} }


@misc{go_spec, @misc{go_spec,
author = "{G}o Authors", author = "{G}o {A}uthors",
title = "{G}o language specification", title = "{G}o language specification",
howpublished = { \url{http://golang.org/doc/go_spec.html}}, howpublished = { \url{http://golang.org/doc/go_spec.html}},
year = 2010 year = 2010
Expand Down
1 change: 1 addition & 0 deletions go_a4.tex
Expand Up @@ -37,6 +37,7 @@
\begin{document} \begin{document}
\thispagestyle{empty} \thispagestyle{empty}
\newcommand{\version}{1.0} \newcommand{\version}{1.0}

%% Title page. %% Title page.
\begin{center} \begin{center}
\hspace{1.0cm}{\scalefont{6.00}{\sffamily{\mbox{\vspace{1.0cm}Learning Go}}}}\\ \hspace{1.0cm}{\scalefont{6.00}{\sffamily{\mbox{\vspace{1.0cm}Learning Go}}}}\\
Expand Down

0 comments on commit d04514a

Please sign in to comment.