Download Complete Learning Go Programming 1st Edition Vladimir Vivien PDF for All Chapters
Download Complete Learning Go Programming 1st Edition Vladimir Vivien PDF for All Chapters
com
https://ebookname.com/product/learning-go-programming-1st-
edition-vladimir-vivien/
OR CLICK BUTTON
DOWNLOAD EBOOK
https://ebookname.com/product/the-way-to-go-a-thorough-introduction-
to-the-go-programming-language-1st-edition-balbaert/
ebookname.com
https://ebookname.com/product/practising-videojournalism-1st-edition-
vivien-morgan/
ebookname.com
https://ebookname.com/product/using-aspect-oriented-programming-for-
trustworthy-software-development-1st-edition-vladimir-o-safonov/
ebookname.com
https://ebookname.com/product/gateway-2nd-edition-anna-cole/
ebookname.com
A Handbook of Middle English Studies 1st Edition Marion
Turner (Editor)
https://ebookname.com/product/a-handbook-of-middle-english-
studies-1st-edition-marion-turner-editor/
ebookname.com
https://ebookname.com/product/gene-transfer-vectors-for-clinical-
application-1st-edition-theodore-friedmann-eds/
ebookname.com
https://ebookname.com/product/armies-of-the-german-peasants-
war-1524-26-douglas-miller/
ebookname.com
Decoding the City How Big Data Can Change Urbanism 1st
Edition Dietmar Offenhuber (Ed.)
https://ebookname.com/product/decoding-the-city-how-big-data-can-
change-urbanism-1st-edition-dietmar-offenhuber-ed/
ebookname.com
https://ebookname.com/product/reasoning-about-uncertainty-joseph-y-
halpern/
ebookname.com
Oceanography and Marine Biology An Annual Review Volume 52
1st Edition R.N. Hughes
https://ebookname.com/product/oceanography-and-marine-biology-an-
annual-review-volume-52-1st-edition-r-n-hughes/
ebookname.com
Learning Go Programming
Vladimir Vivien
BIRMINGHAM - MUMBAI
Learning Go Programming
Copyright © 2016 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or
transmitted in any form or by any means, without the prior written permission of the
publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the
information presented. However, the information contained in this book is sold without
warranty, either express or implied. Neither the author, nor Packt Publishing, and its
dealers and distributors will be held liable for any damages caused or alleged to be caused
directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.
Parth Desai is a polygot programmer and architect, and has worked on almost all popular
languages like Golang, python, C#. He regularly contributes to various open-source golang
projects, like a notification engine called “Khabar”, a http framework written in golang
called “Gottp”, and media server called “moire”. He implemented url signing protocol
using cryptography in python, from scratch.
He has also written custom single sign on solution (SSO) in c#, with proper implementation
of oauth and saml protocols. He also developed pluggable architecture to facilitate easier
adding and removing of authentication providers for the SSO. Currently, He is working as a
lead backend engineer, and designing and implementing scalable systems in golang and
python. You can reach out to him on linkedin at https://in.linkedin.com/in/parthdesa
i08. Or on his email-id desaiparth08@gmail.com.
Abhishek Kumar is a technologist in IT Industry since 2010 mainly working in Systems
Programming, DevOps Practices and Security. He likes to keep in sync with all domains,
paradigms and up-coming technologies to get a wholistic approach for problem solving and
planning ahead. He loves to learn new programming languages. Abhishek has been using
Golang since 2012. He started a timeseries datastore project in Golang by Sep'2013 and is
currently pivoting it. [ @abionic | https://abhishekkr.github.io ]
Chris Schaefer software developer with a passion for learning new things. He enjoys
writing code and participating in local community software events.
www.PacktPub.com
For support files and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF and
ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a
print book customer, you are entitled to a discount on the eBook copy. Get in touch with us
at service@packtpub.com for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a
range of free newsletters and receive exclusive discounts and offers on Packt books and
eBooks.
https://www.packtpub.com/mapt
Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt
books and video courses, as well as industry-leading tools to help you plan your personal
development and advance your career.
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Table of Contents
Preface 1
Chapter 1: A First Step in Go 7
The Go programming language 8
Playing with Go 10
No IDE required 11
Installing Go 11
Source code examples 12
Your first Go program 12
Go in a nutshell 13
Functions 15
Packages 16
The workspace 16
Strongly typed 16
Composite types 17
The named type 18
Methods and objects 18
Interfaces 19
Concurrency and channels 20
Memory management and safety 21
Fast compilation 22
Testing and code coverage 22
Documentation 23
An extensive library 24
The Go Toolchain 25
Summary 25
Chapter 2: Go Language Essentials 26
The Go source file 27
Optional semicolon 29
Multiple lines 30
Go identifiers 32
The blank identifier 32
Muting package imports 32
Muting unwanted function results 33
Built-in identifiers 33
Types 33
Values 34
Functions 34
Go variables 34
Variable declaration 34
The zero-value 36
Initialized declaration 36
Omitting variable types 37
Short variable declaration 39
Restrictions for short variable declaration 40
Variable scope and visibility 40
Variable declaration block 42
Go constants 42
Constant literals 42
Typed constants 43
Untyped constants 43
Assigning untyped constants 44
Constant declaration block 45
Constant enumeration 46
Overriding the default enumeration type 47
Using iota in expressions 47
Skipping enumerated values 48
Go operators 49
Arithmetic operators 49
The increment and decrement operators 49
Go assignment operators 50
Bitwise operators 50
Logical Operators 51
Comparison operators 51
Operator precedence 52
Summary 52
Chapter 3: Go Control Flow 53
The if statement 53
The if statement initialization 57
Switch statements 57
Using expression switches 59
The fallthrough cases 60
Expressionless switches 62
Switch initializer 63
[ ii ]
Type switches 64
The for statements 66
For condition 66
Infinite loop 67
The traditional for statement 68
The for range 70
The break, continue, and goto statements 73
The label identifier 73
The break statement 73
The continue statement 74
The goto statement 75
Summary 76
Chapter 4: Data Types 77
Go types 77
Numeric types 80
Unsigned integer types 81
Signed integer types 81
Floating point types 82
Complex number types 82
Numeric literals 82
Boolean type 84
Rune and string types 84
The rune 85
The string 86
Interpreted and raw string literals 87
Pointers 88
The pointer type 89
The address operator 89
The new() function 91
Pointer indirection – accessing referenced values 92
Type declaration 93
Type conversion 94
Summary 96
Chapter 5: Functions in Go 97
Go functions 97
Function declaration 98
The function type 101
Variadic parameters 102
[ iii ]
Function result parameters 103
Named result parameters 104
Passing parameter values 105
Achieving pass-by-reference 106
Anonymous Functions and Closures 107
Invoking anonymous function literals 108
Closures 108
Higher-order functions 109
Error signaling and handling 110
Signaling errors 111
Error handling 114
The error type 114
Deferring function calls 115
Using defer 117
Function panic and recovery 117
Function panic 117
Function panic recovery 119
Summary 121
Chapter 6: Go Packages and Programs 122
The Go package 122
Understanding the Go package 122
The workspace 124
Creating a workspace 126
The import path 127
Creating packages 128
Declaring the package 129
Multi-File packages 130
Naming packages 131
Use globally unique namespaces 131
Add context to path 132
Use short names 132
Building packages 133
Installing a package 134
Package visibility 134
Package member visibility 135
Importing package 136
Specifying package identifiers 138
The dot identifier 139
The blank identifier 139
[ iv ]
Package initialization 140
Creating programs 141
Accessing program arguments 143
Building and installing programs 145
Remote packages 146
Summary 147
Chapter 7: Composite Types 148
The array type 148
Array initialization 149
Declaring named array types 151
Using arrays 152
Array length and capacity 153
Array traversal 153
Array as parameters 154
The slice type 155
Slice initialization 156
Slice representation 157
Slicing 159
Slicing a slice 160
Slicing an array 161
Slice expressions with capacity 161
Making a slice 162
Using slices 163
Slices as parameters 164
Length and capacity 164
Appending to slices 165
Copying slices 165
Strings as slices 166
The map type 167
Map initialization 167
Making Maps 168
Using maps 169
Map traversal 170
Map functions 171
Maps as parameters 171
The struct type 172
Accessing struct fields 173
Struct initialization 173
Declaring named struct types 174
[v]
The anonymous field 175
Promoted fields 176
Structs as parameters 177
Field tags 178
Summary 179
Chapter 8: Methods, Interfaces, and Objects 180
Go methods 180
Value and pointer receivers 183
Objects in Go 185
The struct as object 186
Object composition 187
Field and method promotion 189
The constructor function 190
The interface type 191
Implementing an interface 192
Subtyping with Go interfaces 193
Implementing multiple interfaces 194
Interface embedding 196
The empty interface type 197
Type assertion 198
Summary 201
Chapter 9: Concurrency 202
Goroutines 202
The go statement 203
Goroutine scheduling 206
Channels 208
The Channel type 208
The send and receive operations 209
Unbuffered channel 209
Buffered channel 211
Unidirectional channels 212
Channel length and capacity 213
Closing a channel 214
Writing concurrent programs 215
Synchronization 215
Streaming data 217
Using for…range to receive data 219
Generator functions 220
Selecting from multiple channels 221
[ vi ]
Channel timeout 223
The sync package 224
Synchronizing with mutex locks 224
Synchronizing access to composite values 226
Concurrency barriers with sync.WaitGroup 227
Detecting race conditions 228
Parallelism in Go 229
Summary 231
Chapter 10: Data IO in Go 232
IO with readers and writers 233
The io.Reader interface 233
Chaining readers 234
The io.Writer interface 236
Working with the io package 239
Working with files 241
Creating and opening files 241
Function os.OpenFile 242
Files writing and reading 243
Standard input, output, and error 245
Formatted IO with fmt 246
Printing to io.Writer interfaces 246
Printing to standard output 247
Reading from io.Reader 247
Reading from standard input 248
Buffered IO 249
Buffered writers and readers 249
Scanning the buffer 251
In-memory IO 252
Encoding and decoding data 253
Binary encoding with gob 254
Encoding data as JSON 256
Controlling JSON mapping with struct tags 259
Custom encoding and decoding 260
Summary 263
Chapter 11: Writing Networked Services 264
The net package 264
Addressing 264
The net.Conn Type 265
[ vii ]
Dialing a connection 265
Listening for incoming connections 267
Accepting client connections 268
A TCP API server 269
Connecting to the TCP server with telnet 272
Connecting to the TCP server with Go 273
The HTTP package 275
The http.Client type 275
Configuring the client 277
Handling client requests and responses 278
A simple HTTP server 279
The default server 281
Routing requests with http.ServeMux 282
The default ServeMux 283
A JSON API server 284
Testing the API server with cURL 286
An API server client in Go 287
A JavaScript API server client 288
Summary 292
Chapter 12: Code Testing 293
The Go test tool 293
Test file names 294
Test organization 294
Writing Go tests 295
The test functions 296
Running the tests 298
Filtering executed tests 299
Test logging 300
Reporting failure 301
Skipping tests 302
Table-driven tests 304
HTTP testing 305
Testing HTTP server code 306
Testing HTTP client code 307
Test coverage 310
The cover tool 310
Code benchmark 312
Running the benchmark 313
Skipping test functions 313
[ viii ]
The benchmark report 314
Adjusting N 314
Comparative benchmarks 315
Summary 317
Index 318
[ ix ]
Preface
Go is an open source programming language that lets programmers easily build reliable
and scalable programs. It does this by offering a simple syntax which makes it fun to write
correct and predictable code using concurrency idioms and a robust standard library.
Go has a large and active online community and there are several Go conferences that take
place around the world yearly. Starting with https://golang.org/, you will find
numerous places on the web that provide documentations, blogs, videos, and slides that
cover a wide range of Go-related topics. On GitHub, the story is no different; some of the
best known projects that are driving the future of cloud computing, for instance, are written
in Go with an ever growing list.
As you would expect, getting started with Go is simple, fast, and well documented.
However, “getting into” Go can be more challenging, especially for newcomers from other
languages. My first attempt at Go failed. Even after reading the prescribed documentations
and going through the tutorials, there was a gap in understanding driven by my own biases
from previous programming experiences. Months later I returned to Go and got into it.
This time I read the language specs, I read blogs, watch videos, and searched the web for
any discussion that provided design motivations and in-depth explanations of the
language.
Learning Go is a book intended to help new, and seasoned programmers alike, to get into
the Go programming language. With this book, I have attempted to write the book I would
have like to have read when I was starting out with Go. It distills the language specs, the
documentations, the blogs, the videos, slides, and my own experiences of writing Go into
content that carefully provides the right amount of depth and insights to help you
understand the language and its design.
Chapter 2, Go Language Essentials, this chapter starts with a deeper exploration Go’s syntax
and other language elements such as source files, variables, and operators.
Preface
Chapter 3, Go Control Flow, examines Go program control flow elements including if, loop,
and switch statements.
Chapter 4, Data Types, introduces its readers to Go’s type system including detail about
built-in types, type declaration, and conversion.
Chapter 5, Functions in Go, discusses the characteristics of the Go function type including
definition, assignment, variadic parameters, and closures.
Chapter 7, Composite Types, this chapter continues the discussion Go types by introducing
the reader to Go’s composite types such as arrays, slices, maps, and structs.
Chapter 8, Methods, Interfaces, and Objects, introduces the reader to Go idioms and features
that can be used to create and compose object structures.
Chapter 9, Concurrency, introduces the reader to the topics of writing concurrent programs
in Go using language constructs such as goroutines and channels.
Chapter 10, Data IO in Go, covers the built-in interfaces and APIs to achieve streaming
input, output, and encoding of data.
Chapter 11, Writing Networked Services, explores the Go’s standard library for creating
connected applications using covering topics from low-level TCP protocols to HTTP an
RPC.
Chapter 12, Code Testing, here readers are introduced to Go’s inherent support and tools for
code testing and benchmarking.
[2]
Preface
Conventions
In this book, you will find a number of text styles that distinguish between different kinds
of information. Here are some examples of these styles and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions,
pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Save the
source code in a file called helloworld.go anywhere inside your GOPATH."
[3]
Preface
New terms and important words are shown in bold. Words that you see on the screen, for
example, in menus or dialog boxes, appear in the text like this: "If all goes well, you should
see the message Hello, World! output on your screen.."
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about this
book-what you liked or disliked. Reader feedback is important for us as it helps us develop
titles that you will really get the most out of. To send us general feedback, simply e-
mail feedback@packtpub.com, and mention the book's title in the subject of your
message. If there is a topic that you have expertise in and you are interested in either
writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to help you
to get the most from your purchase.
1. Log in or register to our website using your e-mail address and password.
2. Hover the mouse pointer on the SUPPORT tab at the top.
3. Click on Code Downloads & Errata.
4. Enter the name of the book in the Search box.
[4]
Preface
5. Select the book for which you're looking to download the code files.
6. Choose from the drop-down menu where you purchased this book from.
7. Click on Code Download.
Once the file is downloaded, please make sure that you unzip or extract the folder using the
latest version of:
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPubl
ishing/Learning-Go-Programming. We also have other code bundles from our rich catalog
of books and videos available at https://github.com/PacktPublishing/. Check them
out!
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do
happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-
we would be grateful if you could report this to us. By doing so, you can save other readers
from frustration and help us improve subsequent versions of this book. If you find any
errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting
your book, clicking on the Errata Submission Form link, and entering the details of your
errata. Once your errata are verified, your submission will be accepted and the errata will
be uploaded to our website or added to any list of existing errata under the Errata section of
that title.
[5]
Preface
Piracy
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At
Packt, we take the protection of our copyright and licenses very seriously. If you come
across any illegal copies of our works in any form on the Internet, please provide us with
the location address or website name immediately so that we can pursue a remedy.
We appreciate your help in protecting our authors and our ability to bring you valuable
content.
Questions
If you have a problem with any aspect of this book, you can contact us
at questions@packtpub.com, and we will do our best to address the problem.
[6]
A First Step in Go
1
In the first chapter of the book, you will be introduced to Go and take a tour of the features
that have made the language a favorite among its adopters. The start of the chapter
provides the motivation behind the Go programming language. If you are impatient,
however, you are welcome to skip to any of the other topics and learn how to write your
first Go program. Finally, the Go in a nutshell section provides a high-level summary of the
characteristics of the language.
In the other evolutionary linguistic branch are languages such as Perl, Python, and
JavaScript that are described as dynamic languages for their lack of type safety formalities,
use of lightweight scripting syntax, and code interpretation instead of compilation.
Dynamic languages have become the preferred tool for web and cloud scale development
where speed and ease of deployment are valued over runtime safety. The interpreted
nature of dynamic languages means, however, they generally run slower than their
compiled counterparts. In addition, the lack of type safety at runtime means the correctness
of the system scales poorly as the application grows.
[8]
Random documents with unrelated
content Scribd suggests to you:
— Voyons, qu’est-ce encore que vous n’êtes pas ? Vous n’êtes pas
Anglais !
— Oh ! nullement.
— Eh bien, vous nous croyez donc assez ridicules pour vous faire
un crime de votre naissance ? Eh ! monsieur, je sais bien qu’il n’est
pas donné à tout le monde d’être Anglais. La terre entière ne peut
pas être Anglaise… au moins avant quelques années. Mais on peut
être honnête homme et homme d’esprit sans être né positivement
en Angleterre.
— Pour ce qui est de la probité, madame, c’est un bien que nous
nous transmettons de père en fils. De l’esprit, j’en ai juste ce qu’il
faut pour être docteur. Mais malheureusement je ne me fais pas
d’illusion sur les défauts de ma personne physique, et…
— Vous voulez dire que vous êtes laid, n’est-ce pas ? Non,
monsieur, vous n’êtes pas laid. Vous avez une figure intelligente.
Mary-Ann, monsieur a-t-il une figure intelligente ?
— Oui, maman, » dit Mary-Ann. Si elle rougit en répondant, sa
mère le vit mieux que moi, car mes yeux étaient obstinément cloués
à terre.
« D’ailleurs, ajouta Mme Simons, fussiez-vous dix fois plus laid,
vous ne le seriez pas encore autant que feu mon mari. Et pourtant je
vous prie de croire que j’étais aussi jolie que ma fille, le jour où je lui
donnai ma main. Que répondrez-vous à cela ?
— Rien, madame, sinon que vous me comblez, et qu’il ne tiendra
pas à moi que vous ne soyez demain sur la route d’Athènes.
— Que comptez-vous faire ? Cette fois tâchez de trouver un
expédient moins ridicule que l’autre jour !
— J’espère que vous serez satisfaite de moi si vous voulez bien
m’entendre jusqu’au bout.
— Oui, monsieur.
— Sans m’interrompre.
— Je ne vous interromprai pas. Vous a-t-on jamais interrompu ?
— Oui.
— Non.
— Si.
— Quand ?
— Jamais. Madame, Hadgi-Stavros a tous ses fonds placés chez
MM. Barley et Cie.
— Chez nous !
— Cavendish-Square, 31, à Londres. Mercredi dernier, il a dicté
devant nous une lettre d’affaires à l’adresse de M. Barley.
— Et vous ne m’avez pas dit cela plus tôt !
— Vous ne m’en avez jamais laissé le temps.
— Mais c’est monstrueux ! Votre conduite est inexplicable ! Nous
serions en liberté depuis six jours. Je serais allée droit à lui ; je lui
aurais dit nos relations…
— Et il vous aurait demandé deux ou trois cent mille francs !
Croyez-moi, madame, le mieux est de ne rien lui dire du tout. Payez
votre rançon ; faites-vous donner un reçu, et dans quinze jours
envoyez-lui un compte courant avec la mention suivante :
« Item, 100.000 francs remis personnellement par Mme Simons,
notre associée, contre reçu. »
De cette façon, vous rentrez dans votre argent, sans le secours
de la gendarmerie. Est-ce clair ? »
Je levai les yeux et je vis le joli sourire de Mary-Ann, tout radieux
de reconnaissance. Mme Simons haussait furieusement les épaules et
ne semblait émue que de dépit.
« En vérité, me dit-elle, vous êtes un homme surprenant ! Vous
êtes venu nous proposer une évasion acrobatique lorsque nous
avions un moyen si simple de nous échapper ! Et vous savez cela
depuis mercredi matin ! Je ne vous pardonnerai jamais de ne pas
nous l’avoir dit le premier jour.
— Mais, madame, veuillez vous rappeler que je vous priais
d’écrire à monsieur votre frère pour lui demander cent quinze mille
francs.
— Pourquoi cent quinze ?
— Je veux dire cent mille.
— Non ; cent quinze. C’est trop juste. Êtes-vous bien sûr que ce
Stavros ne nous retiendra pas ici lorsqu’il aura reçu l’argent ?
— Je vous en réponds. Les brigands sont les seuls Grecs qui ne
manquent jamais à leur parole. Vous comprenez que s’il leur arrivait
une fois de garder les prisonniers après avoir touché la rançon,
personne ne se rachèterait plus.
— Il est vrai. Mais quel singulier Allemand vous faites, de n’avoir
pas parlé plus tôt !
— Vous m’avez toujours coupé la parole.
— Il fallait parler quand même !
— Mais, madame…
— Taisez-vous ? et conduisez-nous à ce maudit Stavros. »
Le Roi déjeunait d’un rôti de tourterelles, sous son arbre de
justice, avec les officiers valides qui lui restaient encore. Sa toilette
était faite : il avait lavé le sang de ses mains et changé d’habit. Il
cherchait avec ses convives le moyen le plus expéditif de combler les
vides que la mort avait faits dans ses rangs. Vasile, qui était de
Janina, offrait d’aller lever trente hommes en Épire, où la
surveillance des autorités turques a mis plus de mille brigands en
retrait d’emploi. Un Laconien voulait qu’on acquît à beaux deniers
comptants la petite bande du Spartiate Pavlos, qui exploitait la
province du Magne, dans le voisinage de Calamata. Le Roi, toujours
imbu des idées anglaises, pensait à organiser un recrutement par
force et à enlever tous les bergers de l’Attique. Ce système semblait
d’autant plus avantageux qu’il n’entraînait aucun débours, et qu’on
gagnait les troupeaux par-dessus le marché.
Interrompu au milieu de la délibération, Hadgi-Stavros fit à ses
prisonnières un accueil glacial. Il n’offrit pas même un verre d’eau à
Mme Simons, et comme elle n’avait point déjeuné, elle fut sensible à
cet oubli des convenances. Je pris la parole au nom des Anglaises,
et, en l’absence du Corfiote, le Roi fut bien forcé de m’accepter pour
intermédiaire. Je lui dis qu’après le désastre de la veille il serait
content d’apprendre la détermination de Mme Simons ; qu’elle avait
résolu de payer, dans le plus bref délai, sa rançon et la mienne ; que
les fonds seraient versés le lendemain, soit à la Banque d’Athènes,
soit en tout autre lieu qu’il lui plairait de désigner, contre son reçu.
« Je suis bien aise, dit-il, que ces femmes aient renoncé à
convoquer l’armée grecque à leur secours. Dites-leur qu’on leur
remettra, pour la seconde fois, tout ce qu’il faut pour écrire, mais
qu’elles n’abusent plus de ma confiance ! qu’elles ne m’attirent pas
les soldats ici ! Au premier pompon qui paraît dans la montagne, je
leur fais couper la tête. Je le jure par la Vierge du Mégaspiléon, qui
fut sculptée de la propre main de saint Luc !
— N’ayez aucun doute. J’engage la parole de ces dames et la
mienne. Où voulez-vous que les fonds soient déposés ?
— A la Banque nationale de Grèce. C’est la seule qui n’ait pas
encore fait banqueroute.
— Avez-vous un homme sûr pour porter la lettre ?
— J’ai le bon vieillard. On va le faire appeler. Quelle heure est-il ?
Neuf heures du matin. Le révérend n’a pas encore assez bu pour
être gris.
— Va pour le moine ! Lorsque le frère de Mme Simons aura versé
la somme et pris votre reçu, le moine viendra vous en porter la
nouvelle.
— Quel reçu ? Pourquoi un reçu ? Je n’en ai jamais donné. Quand
vous serez tous en liberté, on verra bien que vous m’avez payé ce
qui m’était dû.
— Je croyais qu’un homme comme vous devait traiter les affaires
à la mode d’Europe. En bonne administration…
— Je traite les affaires à ma guise, et je suis trop vieux pour
changer la méthode.
— Comme il vous plaira. Je vous demandais cela dans l’intérêt de
Mme Simons. Elle est tutrice de sa fille mineure, et elle lui devra
compte de la totalité de sa fortune.
— Qu’elle s’arrange ! Je me soucie de ses intérêts comme elle des
miens. Quand elle payerait pour sa fille, le grand malheur ! Je n’ai
jamais regretté ce que je débourse pour Photini. Voici du papier, de
l’encre et des roseaux. Soyez assez bon pour surveiller la rédaction
de la lettre. Il y va de votre tête aussi. »
Je me levai tout penaud et je suivis ces dames qui devinaient ma
confusion sans en pénétrer la cause. Mais une inspiration soudaine
me fit revenir sur mes pas. Je dis au Roi : « Décidément, vous avez
bien fait de refuser le reçu, et j’ai eu tort de le demander. Vous êtes
plus sage que moi ; la jeunesse est imprudente.
— Qu’est-ce à dire ?
— Vous avez raison, vous dis-je. Il faut s’attendre à tout. Qui sait
si vous n’essuierez pas une seconde défaite plus terrible que la
première ? Comme vous n’aurez pas toujours vos jambes de vingt
ans, vous pourriez tomber vivant aux mains des soldats.
— Moi !
— On vous ferait votre procès comme à un simple malfaiteur ; les
magistrats ne vous craindraient plus. En pareille circonstance, un
reçu de cent quinze mille francs serait une preuve accablante. Ne
donnez pas d’armes à la justice contre vous. Peut-être Mme Simons
ou ses héritiers se porteraient-ils parties civiles pour revendiquer ce
qui leur a été pris. Ne signez jamais de reçus ! »
Il répondit d’une voix tonnante : « J’en signerai ! Et plutôt deux
qu’un ! J’en signerai tant qu’on en voudra ! J’en signerai toujours, et
à tout le monde. Ah ! les soldats s’imaginent qu’ils auront bon
marché de moi, parce qu’une fois le hasard et le nombre leur ont
donné l’avantage ! Je tomberais vivant entre leurs mains, moi dont le
bras est à l’épreuve de la fatigue et la tête à l’épreuve des balles !
J’irais m’asseoir sur un banc, devant un juge, comme un paysan qui
a volé des choux ! Jeune homme, vous ne connaissez pas encore
Hadgi-Stavros. Il serait plus facile de déraciner le Parnès et de le
planter sur la cime du Taygète, que de m’arracher de mes
montagnes pour me jeter sur le banc d’un tribunal ! Écrivez-moi en
grec le nom de Mme Simons ! Bien. Le vôtre aussi !
— Il n’est pas nécessaire, et…
— Écrivez toujours. Vous savez mon nom, et je suis sûr que vous
ne l’oublierez pas. Je veux avoir le vôtre, pour m’en souvenir. »
Je griffonnai mon nom comme je pus, dans la langue
harmonieuse de Platon. Les lieutenants du Roi applaudirent à sa
fermeté sans prévoir qu’elle lui coûtait cent quinze mille francs. Je
courus, content de moi et le cœur léger, à la tente de Mme Simons.
Je lui racontai que son argent l’avait échappé belle, et elle daigna
sourire en apprenant comment je m’y étais pris pour voler nos
voleurs. Une demi-heure après, elle soumit à mon approbation la
lettre suivante :
« Du Parnèse,
au milieu des démons de ce Stavros.
« Rebecca Simons.
« Chère sœur,
« Tout à vous,
« Edward Sharper. »