Preface....3
Part I: The GO language....9
Chapter 1 First steps with Go....10
1.1 Save the world with Go!!!....10
1.2 Passing arguments to our program....11
1.3 Summary....19
Chapter 2 The basics....21
2.1 Packages and imports....21
2.2 Variables, constants, and enums....22
2.3 Functions....29
2.4 Pointers....34
2.5 nil and zero values....35
2.6 Loops and branches....36
2.7 Errors....43
2.8 Defer, panic, and recover....45
2.9 Init functions....48
2.10 Summary....51
Chapter 3 Arrays, slices, and maps....52
3.1 Arrays....52
3.2 Slices....53
3.3 Maps....60
3.4 Summary....63
Chapter 4 Structs, methods, and interfaces....64
4.1 Structs....64
4.2 Methods....71
4.3 Interfaces....76
4.4 Summary....82
Chapter 5 Reflection....83
5.1 reflect.Type....83
5.2 reflect.Value....88
5.3 Creating functions on the fly....94
5.4 Tags....97
5.5 The three laws of reflection....99
5.6 Summary....101
Chapter 6 Concurrency....102
6.1 Goroutines....102
6.2 Channels....104
6.3 Select....113
6.4 WaitGroup....119
6.5 Timers, tickers, and timeouts....121
6.6 Context....125
6.7 Once....134
6.8 Mutexes....136
6.9 Atomics....138
6.10 Summary....142
Chapter 7 Input/Output....143
7.1 Readers and writers....143
7.2 Reading and Writing files....147
7.3 Standard I/O....151
7.4 Summary....156
Chapter 8 Encodings....157
8.1 CSV....157
8.2 JSON....160
8.3 XML....165
8.4 YAML....172
8.5 Tags and encoding....176
8.6 Summary....182
Chapter 9 HTTP....183
9.1 Requests....183
9.2 HTTP Server....192
9.3 Cookies....195
9.4 Middleware....201
9.5 Summary....207
Chapter 10 Templates....208
10.1 Filling templates with structs....208
10.2 Actions....210
10.3 Functions....214
10.4 HTML....218
10.5 Summary....220
Chapter 11 Testing....221
11.1 Tests....221
11.2 Examples....235
11.3 Benchmarking....239
11.4 Coverage....242
11.5 Profiling....245
11.6 Summary....251
Chapter 12 Modules and documentation....252
12.1 Modules....252
12.2 Documentation....254
12.3 Summary....258
Part II: Building systems....259
Chapter 13 Protocol buffers....260
13.1 The proto file....260
13.2 Complex messages....264
13.3 Importing other proto definitions....267
13.4 Nested types....270
13.5 Type Any....272
13.6 Type Oneof....274
13.7 Maps....277
13.8 JSON....279
13.9 Summary....281
Chapter 14 gRPC....282
14.1 Definition of services....283
14.2 Creating a server....285
14.3 Creating clients....288
14.4 Streaming....290
14.5 Transcoding....310
14.6 Interceptors....317
14.7 Summary....325
Chapter 15 Logging with Zerolog....326
15.1 The log package....326
15.2 Zerolog basics....328
15.3 Zerolog settings....334
15.4 Zerolog advanced settings....340
15.5 Summary....348
Chapter 16 Command Line Interface....349
16.1 The basics....349
16.2 Arguments and Flags....352
16.3 Commands....360
16.4 Advanced features....369
16.5 Summary....379
Chapter 17 Relational databases....381
17.1 SQL in Go....381
17.2 GORM....389
17.3 Manipulate data....399
17.4 Summary....413
Chapter 18 NoSQL databases....414
18.1 Cassandra and GoCQL....414
18.2 Summary....432
Chapter 19 Kafka....433
19.1 The basics....433
19.2 Using the Confluent client....435
19.3 Using the Segmentio client....446
19.4 Using the Kafka REST API....452
19.5 Summary....462
Bibliography....467
Notes....468
Because to build a system you need more than a collection of loops, this book offers the reader a complete explanation of the most useful aspects of the Go language, and how to use them with existing tools from the Go ecosystem. Do not stay in the basics, move forward and learn how to build systems with restful APIs, gRPC messaging, powerful loggers, middleware, SQL/noSQL databases, data streaming, and more. A book written for new adopters and experienced developers.