forked from miekg/gobook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgo-preface.tex
98 lines (82 loc) · 3.96 KB
/
go-preface.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
\epi{``Is Go an object-oriented language? Yes and no.''}
{\textit{Frequently asked questions}\\ \textsc{GO AUTHORS}}
\section*{Audience}
\noindent{}This is an introduction to the Go language from Google. Its aim
is to provide a guide to this new and innovative language.
The intended audience of this book is people who are familiar with programming
and know some programming languages, be it C\cite{c}, C++\cite{c++},
Perl\cite{perl}, Java\cite{java}, Erlang\cite{erlang}, Scala\cite{scala} or
Haskell\cite{haskell}. This is \emph{not} a book that teaches you how to
program, this is a book that just teaches you how to use Go.
As with
learning new things, probably the best way to do this is to discover it for
yourself by creating your own programs.
Each chapter therefore includes a number of exercises (and answers)
to acquaint you with the language.
An exercise
is numbered as \textbf{Q$n$}, where $n$ is a number. After the
exercise number another number in parentheses displays the difficulty
of this particular assignment. This difficulty ranges from 0 to
2:
\begin{enumerate}
\setcounter{enumi}{-1}
\item easy;
\item intermediate;
\item difficult.
\end{enumerate}
Then a short name is given, for easier reference.
For example:
\begin{verse}
\textbf{Q1}. (1) A map function \ldots
\end{verse}
introduces a question numbered \textbf{Q1} of a level 1 difficulty, concerning a
\func{map()}-function. The answers are included after the exercises on a
new page.
The numbering and setup of the answers is identical to the
exercises, except that an answer starts with \textbf{A$n$}, where the
number $n$ corresponds with the number of the exercise. Some exercises
don't have an answer; these are marked with an asterisk.
\section*{Book layout}
\begin{description}
\item[Chapter \ref{chap:intro}: \titleref{chap:intro}]
A short introduction and history of Go. It
describes how to get the source code of Go itself. It assumes a Unix-like environment, although
Go should be fully usable on Windows.
\item[Chapter \ref{chap:basics}: \titleref{chap:basics}]
Describes the basic types, variables and control
structures available in the language.
\item[Chapter \ref{chap:functions}: \titleref{chap:functions}]
In the third chapter we look at functions, the basic building blocks of Go programs.
\item[Chapter \ref{chap:packages}: \titleref{chap:packages}]
In chapter \ref{chap:packages} we see that functions and data can be grouped together
in packages. You will also see how to document and test your packages.
\item[Chapter \ref{chap:beyond}: \titleref{chap:beyond}]
After that we look at creating your own types in chapter \ref{chap:beyond}. It also
looks at allocation in Go.
\item[Chapter \ref{chap:interfaces}: \titleref{chap:interfaces}]
Go does not support object orientation in the traditional sense.
In Go the central concept is interfaces.
\item[Chapter \ref{chap:channels}: \titleref{chap:channels}]
With the \func{go} keyword functions can be started in separate routines (called goroutines).
Communication with those goroutines is done via channels.
\item[Chapter \ref{chap:communication}: \titleref{chap:communication}]
In the last chapter we show how to interface with the rest of the world from within
a Go program. How to create files and read and write from and to them. We also briefly
look into networking.
\end{description}
I hope you will enjoy this book and the language Go.
\section*{Settings used in this book}
\begin{itemize}
\item Go itself is installed in \file{\~{}/go}, and \var{\$GOROOT} is set to \var{GOROOT=\~{}/go} ;
\item Go source code we want to compile ourself is placed in \file{\~{}/g/src} and
\var{\$GOPATH} is set to \var{GOPATH=\~{}/g} .
\end{itemize}
\section*{Translations}
The content of this book is freely available. This has already led to translations:
\begin{itemize}
\item{Chinese translation by Xing Xing, 这里是中文译本:
{\url{http://www.mikespook.com/learning-go/}} .}
\end{itemize}
\begin{flushright}
Miek Gieben, 2011, 2012 -- \url{[email protected]}
\end{flushright}