-
Notifications
You must be signed in to change notification settings - Fork 0
/
essential-go.tex
259 lines (211 loc) · 5.39 KB
/
essential-go.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
\documentclass[10pt, a4paper]{book}
\def\myauthor{Baiju Muthukadan}
\def\mytitle{Essentials of Go Programming}
\def\mycopyright{\myauthor}
\def\mykeywords{Baiju, Muthukadan, Go, Golang, Programming, Book}
\def\mybibliostyle{plain}
\def\mybibliocommand{}
\def\mysubtitle{}
\def\myaffiliation{}
\def\myaddress{}
\def\myemail{[email protected]}
\def\myweb{https://muthukadan.net}
\def\myphone{+91 9945973441}
\def\myversion{}
\def\myrevision{}
\usepackage[paperwidth=6.69in, paperheight=9.61in]{geometry}
\usepackage[none]{hyphenat}
\usepackage{listings}
\usepackage{listings-golang}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage[utf8]{inputenc}
\usepackage{imakeidx}
\usepackage{tabularx}
\usepackage{hologo}
\usepackage{caption}
\usepackage{framed}
\usepackage{fancybox}
\usepackage{fancyvrb}
\usepackage{fancyhdr}
\usepackage{tikz}
\usepackage{mathtools}
\usepackage[xetex,
colorlinks,
citecolor=black,
filecolor=black,
linkcolor=black,
urlcolor=black,
plainpages=false,
pdfpagelabels,
bookmarksnumbered,
pdftitle={\mytitle},
pagebackref,
pdfauthor={\myauthor},
pdfkeywords={\mykeywords}
]{hyperref}
\usepackage[Bjornstrup]{fncychap}
\usepackage{upquote}
\usepackage{textcomp}
\usepackage{afterpage}
\usepackage{sectsty}
\usepackage[all]{nowidow}
\usepackage{etoolbox,environ}
\newtoggle{ebook}
\toggletrue{ebook}
\NewEnviron{ebookr}
{\iftoggle{ebook}{\BODY}{}}
\makeatletter
\@ifpackageloaded{tex4ht}{%
\togglefalse{ebook}
% Packages for tex4ht
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
}{%
% Packages for xelatex
\usepackage{fontspec}
\usepackage{xunicode}
\setmainfont[ Path = fonts/,
UprightFont = DejaVuSerif.ttf,
ItalicFont = DejaVuSerif-Italic.ttf,
BoldFont = DejaVuSerif-Bold.ttf,
BoldItalicFont = DejaVuSerif-BoldItalic.ttf,
Numbers={Lining, Monospaced},
] {DejaVu Serif}
\setsansfont[ Path = fonts/,
UprightFont = DejaVuSans.ttf,
ItalicFont = DejaVuSans-Oblique.ttf,
BoldFont = DejaVuSans-Bold.ttf,
BoldItalicFont = DejaVuSans-BoldOblique.ttf,
Numbers={Lining, Monospaced},
] {DejaVu Sans}
\setmonofont[ Path = fonts/,
UprightFont = SourceCodePro-Semibold.ttf,
BoldFont = SourceCodePro-Bold.ttf,
Numbers={Lining, Monospaced},
] {Source Code Pro}
\defaultfontfeatures{Mapping=tex-text} % To support LaTeX quoting style
}
\makeatother
\date{}
%% \renewcommand\contentsname{Table Of Contents}
% Do not indent first line of paragraph.
\setlength{\parindent}{0pt}
\setlength{\parskip}{5pt plus 2pt minus 1pt}
\newlength{\admonitionwidth}
\setlength{\admonitionwidth}{0.9\textwidth}
\newlength{\docinfowidth}
\setlength{\docinfowidth}{0.9\textwidth}
% Less strict (opposite to default fussy) space size between words.
% Therefore less hyphenation.
\sloppy
\makeindex
\lstset{linewidth=\textwidth}
\lstset{ %
basicstyle=\ttfamily\small, % the size of the fonts that are used for the code
showstringspaces=false, % underline spaces within strings
numbers=left, % where to put the line-numbers
numberstyle=\footnotesize, % the size of the fonts that are used for the line-numbers
stepnumber=1, % the step between two line-numbers. If it's 1 each line will be numbered
numbersep=8pt, % how far the line-numbers are from the code
numberblanklines=false,
tabsize=4,
}
\captionsetup[lstlisting]{
justification=centering,
singlelinecheck=false,
margin=0pt,
font={it,footnotesize} }
\setlength{\headheight}{15.2pt}
\pagestyle{fancy}
\lhead[Essentials of Go Programming]{Essentials of Go Programming}
%\chead[<even output>]{<odd output>}
\rhead{}
\fancyhead{}
\fancyfoot{}
\fancyhead[RO,LE]{\thepage}
\fancyhead[LO]{\leftmark}
\fancyhead[RE]{\rightmark}
\renewcommand{\chaptermark}[1]{%
\markboth{\chaptername
\ \thechapter.\ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}
\makeatletter
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
\hbox{}
\vspace*{\fill}
\begin{center}
\end{center}
\vspace{\fill}
\thispagestyle{plain}
\newpage
\if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother
\hypersetup{
pdfborder = {0 0 0}
}
\widowpenalty10000
\clubpenalty10000
\setcounter{secnumdepth}{1}
\setcounter{tocdepth}{1}
\makeatletter
\renewcommand*{\numberline}[1]{\hb@xt@3em{#1\hfil}}
\makeatother
\newcommand\blankpage{%
\null
\thispagestyle{empty}%
\addtocounter{page}{-1}%
\newpage}
\urldef{\effgo}\url{https://go.dev/doc/effective_go#constants}
\begin{document}
\frontmatter
\setcounter{page}{0}
\pagenumbering{roman}
\input{./title.tex}
\thispagestyle{plain}
\input{./copyright.tex}
\cleardoublepage
\thispagestyle{empty} %% Remove header and footer.
\vspace*{2in}
\begin{center}
{\it To my mother Sulochana M.I.}
\end{center}
\newpage
\thispagestyle{plain}
\tableofcontents
\newpage
\thispagestyle{plain}
\input{./preface.tex}
\input{./acknowledgements.tex}
\newpage
\thispagestyle{plain}
\mainmatter
\pagenumbering{arabic}
\setcounter{page}{1}
\input{./introduction.tex}
\input{./quickstart.tex}
\input{./control-structures.tex}
\input{./data-structures.tex}
\input{./functions.tex}
\input{./objects.tex}
\input{./concurrency.tex}
\input{./packages.tex}
\input{./io.tex}
\input{./testing.tex}
\input{./tooling.tex}
%% \appendix
\input{./answers.tex}
%% \input{./vim-config.tex}
%% \input{./edition2/securing-api.tex}
\input{./biblio.tex}
\begin{ebookr}
\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{Index}
\printindex
\end{ebookr}
\blankpage
\input{./colophon.tex}
%% \blankpage
%% \blankpage
\backmatter
\end{document}