Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add fabian

  • Loading branch information...
commit d04514aefe1f9b00bc7d6d7b300feace46b89766 1 parent 86fa47b
@miekg authored
View
5 ex-communication/ex-finger.tex
@@ -20,6 +20,9 @@
\end{Exercise}
\begin{Answer}
+\begin{lbar}
+This solution is from Fabian Becker.
+\end{lbar}
\Question
-Supply code and it may get included here.
+\lstinputlisting[label=src:fingerd,caption=A finger daemon]{ex-communication/src/finger.go}
\end{Answer}
View
7 ex-communication/ex-quine.tex
@@ -5,9 +5,12 @@
\end{Exercise}
\begin{Answer}
+\begin{lbar}
+This solution is from Russ Cox. It was posted to
+the Go Nuts mailing list.
+\end{lbar}
\Question
-The following Quine is from Russ Cox:
-\begin{lstlisting}
+\begin{lstlisting}[caption=A Go quine]
/* Go quine */
package main
import "fmt"
View
53 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
+}
View
1  go-contributors.tex
@@ -9,6 +9,7 @@
\emph{Cecil New},
\emph{Damian Gryski},
\emph{Dan Kortschak},
+\emph{Fabian Becker},
\emph{Filip Zaludek},
\emph{Haiping Fan},
\emph{Jaap Akkerhuis},
View
6 go.bib
@@ -34,7 +34,7 @@ @misc{duck_typing
}
@misc{bubblesort,
- author = "Wikipedia",
+ author = "{W}ikipedia",
howpublished = {\url{http://en.wikipedia.org/wiki/Bubble_sort}},
title = "Bubble sort",
year = 2010
@@ -42,13 +42,13 @@ @misc{bubblesort
@misc{go_nuts,
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}},
year = 2010
}
@misc{go_spec,
- author = "{G}o Authors",
+ author = "{G}o {A}uthors",
title = "{G}o language specification",
howpublished = { \url{http://golang.org/doc/go_spec.html}},
year = 2010
View
1  go_a4.tex
@@ -37,6 +37,7 @@
\begin{document}
\thispagestyle{empty}
\newcommand{\version}{1.0}
+
%% Title page.
\begin{center}
\hspace{1.0cm}{\scalefont{6.00}{\sffamily{\mbox{\vspace{1.0cm}Learning Go}}}}\\
Please sign in to comment.
Something went wrong with that request. Please try again.