Table of Contents

Copyright

Brief Table of Contents

Table of Contents

Foreword

Preface

Acknowledgments

About this Book

About the Authors

About the Cover Illustration

1. Background and fundamentals

Chapter 1. Getting into Go

1.1. What is Go?

1.2. Noteworthy aspects of Go

1.2.1. Multiple return values

1.2.2. A modern standard library

1.2.3. Concurrency with goroutines and channels

1.2.4. Go the toolchain—more than a language

1.3. Go in the vast language landscape

1.3.1. C and Go

1.3.2. Java and Go

1.3.3. Python, PHP, and Go

1.3.4. JavaScript, Node.js, and Go

1.4. Getting up and running in Go

1.4.1. Installing Go

1.4.2. Working with Git, Mercurial, and version control

1.4.3. Exploring the workspace

1.4.4. Working with environment variables

1.5. Hello, Go

1.6. Summary

Chapter 2. A solid foundation

2.1. Working with CLI applications, the Go way

2.1.1. Command-line flags

2.1.2. Command-line frameworks

2.2. Handling configuration

Technique 3 Using configuration files

Technique 4 Configuration via environment variables

2.3. Working with real-world web servers

2.3.1. Starting up and shutting down a server

2.3.2. Routing web requests

2.4. Summary

Chapter 3. Concurrency in Go

3.1. Understanding Go’s concurrency model

3.2. Working with goroutines

Technique 10 Using goroutine closures

Technique 11 Waiting for goroutines

Technique 12 Locking with a mutex

3.3. Working with channels

Technique 13 Using multiple channels

Technique 14 Closing channels

Technique 15 Locking with buffered channels

3.4. Summary

2. Well-rounded applications

Chapter 4. Handling errors and panics

4.1. Error handling

Technique 16 Minimize the nils

Technique 17 Custom error types

Technique 18 Error variables

4.2. The panic system

4.2.1. Differentiating panics from errors

4.2.2. Working with panics

4.2.3. Recovering from panics

4.2.4. Panics and goroutines

4.3. Summary

Chapter 5. Debugging and testing

5.1. Locating bugs

5.1.1. Wait, where is my debugger?

5.2. Logging

5.2.1. Using Go’s logger

5.2.2. Working with system loggers

5.3. Accessing stack traces

Technique 26 Capturing stack traces

5.4. Testing

5.4.1. Unit testing

5.4.2. Generative testing

5.5. Using performance tests and benchmarks

Technique 29 Benchmarking Go code

Technique 30 Parallel benchmarks

Technique 31 Detecting race conditions

5.6. Summary

3. An interface for your applications

Chapter 6. HTML and email template patterns

6.1. Working with HTML templates

6.1.1. Standard library HTML package overview

6.1.2. Adding functionality inside templates

6.1.3. Limiting template parsing

6.1.4. When template execution breaks

6.1.5. Mixing templates

6.2. Using templates for email

Technique 38 Generating email from templates

6.3. Summary

Chapter 7. Serving and receiving assets and forms

7.1. Serving static content

Technique 39 Serving subdirectories

Technique 40 File server with custom error pages

Technique 41 Caching file server

Technique 42 Embedding files in a binary

Technique 43 Serving from an alternative location

7.2. Handling form posts

7.2.1. Introduction to form requests

7.2.2. Working with files and multipart submissions

7.2.3. Working with raw multipart data

7.3. Summary

Chapter 8. Working with web services

8.1. Using REST APIs

8.1.1. Using the HTTP client

8.1.2. When faults happen

8.2. Passing and handling errors over HTTP

8.2.1. Generating custom errors

8.2.2. Reading and using custom errors

8.3. Parsing and mapping JSON

Technique 53 Parsing JSON without knowing the schema

8.4. Versioning REST APIs

Technique 54 API version in the URL

Technique 55 API version in content type

8.5. Summary

4. Taking your applications to the cloud

Chapter 9. Using the cloud

9.1. What is cloud computing?

9.1.1. The types of cloud computing

9.1.2. Containers and cloud-native applications

9.2. Managing cloud services

9.2.1. Avoiding cloud provider lock-in

9.2.2. Dealing with divergent errors

9.3. Running on cloud servers

9.3.1. Performing runtime detection

9.3.2. Building for the cloud

9.3.3. Performing runtime monitoring

9.4. Summary

Chapter 10. Communication between cloud services

10.1. Microservices and high availability

10.2. Communicating between services

10.2.1. Making REST faster

10.2.2. Moving beyond REST

10.3. Summary

Chapter 11. Reflection and code generation

11.1. Three features of reflection

Technique 66 Switching based on type and kind

Technique 67 Discovering whether a value implements an interface

Technique 68 Accessing fields on a struct

11.2. Structs, tags, and annotations

11.2.1. Annotating structs

11.2.2. Using tag annotations

11.3. Generating Go code with Go code

Technique 70 Generating code with go generate

11.4. Summary

Index

List of Figures

List of Listings

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.136.186