Everyday Golang - The Fast Track

Everyday Golang - The Fast Track

Everyday Golang - The Fast Track
Автор: Ellis Alex
Дата выхода: 2021
Издательство: Самиздат
Количество страниц: 157
Размер файла: 764.8 KB
Тип файла: PDF
Добавил: codelibs
 Проверить на вирусы

 Introduction....6

How to use the book....6

Help the book to evolve....7

Changelog....7

Why Go?....7

Getting started with Go....8

A note for Windows users....9

Direct installation on Linux....9

Packages and paths....9

Vendoring and Go modules....11

Create your first Go program....13

Add an external dependency....14

Make use of flags....16

Define a separate package or library....18

Cross-compile for different operating systems....22

Go build arguments....22

CGO and portability....23

Fetch JSON from a HTTP endpoint....24

Get started....24

Learn to parse JSON....25

Retrieve the JSON via HTTP....26

Extracting additional data from the JSON....29

Five ways to write an awesome CLI....31

Pick Go....31

Parse flags & arguments....32

Automate everything....33

Integrate with package managers....34

Accept contributions and gather feedback....35

Now, Go and write your CLI....35

Writing unit-tests in Golang....36

Testing opinions....36

Testing the Sum method....38

Adding a test table....40

Party tricks for ``go test''....41

Statement coverage....41

Generating an HTML coverage report....41

Benchmarking your code....42

Go doesn't ship your tests....43

Stress testing your tests....43

Running tests in parallel....43

Compile the tests to a binary....47

Isolating dependencies....48

Example of isolating dependencies....50

Unit-testing a HTTP server....52

Work concurrently work with Goroutines....56

A simple example with Goroutines....56

Avoid a common mistake with Goroutines....58

Error groups....60

Limiting requests to expensive resources....61

Sharing data between Goroutines....65

Using channels for synchronisation....68

Using a context to handle timeouts....70

Limiting concurrent work....72

Store data with a database....77

Write your own config files in YAML....82

A practical example of YAML in action....82

Read and write your own YAML schema....82

Merging objects....84

Inject version information into your binaries....87

Capture useful variable(s)....87

Prepare your code....88

Do it with Docker....90

Examples in production....90

Embed data in your application....92

Create dynamic content with templates....94

Advanced templates: ranges and custom functions....95

Real-world templates - arkade....97

Write a HTTP server....100

Reading the request....101

Advanced route handling....102

Writing HTTP middleware....104

Add Prometheus metrics to your microservices....106

Tracking HTTP metrics for our microservice....111

Adding custom metrics to your Prometheus data....114

The Prometheus Collector interface....116

Building and releasing Go binaries....120

The release-it example....120

Releasing your binaries with a GitHub Action....121

Releasing a Docker container image....123

Going multi-arch....124

Shipping a Docker container from GitHub Actions....125

Your onward journey....127

Giving feedback....127

Contributing to Open Source....127

My other content....127

OpenFaaS and Go....128

Topics covered....128

Serverless use-cases....128

Introduction to OpenFaaS....129

The value vs cloud functions....129

Pros and Cons....130

Where can you run OpenFaaS functions?....130

The Go template for OpenFaaS....130

Your first function....132

Building your function....134

Adding unit tests to your function....135

Iterating locally....136

Split code into multiple files....137

Introduce a sub-package....139

Working with secrets and databases....140

Create the todo-fn example....140

Exploring the request....143

The complete example....149

Managing config between multiple environments....154

Futher tasks....154

Custom domains and routes....155

Where to go next....157

"Everyday Go" is the fast way to learn tools, techniques and patterns from real tools used in production.This book is a compilation of practical examples, lessons and techniques for Go developers. The topics cover the software lifecycle from learning the fundamentals, to software testing, to distribution and monitoring.If you feel like you may have seen some of these techniques before, you would be right. I've been writing about Go since 2015 and wanted to take everything that I've needed on a regular basis, and to lay it out for you to benefit from.It's not a reference book or a complete guide to the language, but if you like learning by example and aren't afraid to get your feet wet, then this style is probably for you.Features my top rated content on Writing unit-tests in Go, updated, extended and modernised for 2021, as featured in the Kubernetes documentation.Read the launch post: I wrote a book about Everyday Go.


Похожее:

Список отзывов:

Нет отзывов к книге.