Book description
Bridge the gap between basic understanding of Go and use of its advanced features
About This Book
- Discover a number of recipes and approaches to develop modern back-end applications
- Put to use the best practices to combine the recipes for sophisticated parallel tools
- This book is based on Go 1.8, which is the latest version
Who This Book Is For
This book is for web developers, programmers, and enterprise developers. Basic knowledge of the Go language is assumed. Experience with back-end application development is not necessary, but may help understand the motivation behind some of the recipes.
What You Will Learn
- Test your application using advanced testing methodologies
- Develop an awareness of application structures, interface design, and tooling
- Create strategies for third-party packages, dependencies, and vendoring
- Get to know tricks on treating data such as collections
- Handle errors and cleanly pass them along to calling functions
- Wrap dependencies in interfaces for ease of portability and testing
- Explore reactive programming design patterns in Go
In Detail
Go (a.k.a. Golang) is a statically-typed programming language first developed at Google. It is derived from C with additional features such as garbage collection, type safety, dynamic-typing capabilities, additional built-in types, and a large standard library.
This book takes off where basic tutorials on the language leave off. You can immediately put into practice some of the more advanced concepts and libraries offered by the language while avoiding some of the common mistakes for new Go developers.
The book covers basic type and error handling. It explores applications that interact with users, such as websites, command-line tools, or via the file system. It demonstrates how to handle advanced topics such as parallelism, distributed systems, and performance tuning. Lastly, it finishes with reactive and serverless programming in Go.
Style and approach
This guide is a handy reference for developers to quickly look up Go development patterns. It is a companion to other resources and a reference that will be useful long after reading it through the first time. Each recipe includes working, simple, and tested code that can be used as a reference or foundation for your own applications.
Table of contents
- Preface
- I/O and File Systems
- Command-Line Tools
-
Data Conversion and Composition
- Introduction
- Converting data types and interface casting
- Working with numeric data types using math and math/big
- Currency conversions and float64 considerations
- Using pointers and SQL NullTypes for encoding and decoding
- Encoding and decoding Go data
- Struct tags and basic reflection in Go
- Implementing collections via closures
-
Error Handling in Go
- Introduction
- Handling errors and the Error interface
- Using the pkg/errors package and wrapping errors
- Using the log package and understanding when to log errors
- Structured logging with the apex and logrus packages
- Logging with the context package
- Using package-level global variables
- Catching panics for long running processes
- All about Databases and Storage
-
Web Clients and APIs
- Introduction
- Initializing, storing, and passing http.Client structs
- Writing a client for a REST API
- Executing parallel and async client requests
- Making use of OAuth2 clients
- Implementing an OAuth2 token storage interface
- Wrapping a client in added functionality and function composition
- Understanding GRPC clients
-
Microservices for Applications in Go
- Introduction
- Working with web handlers, requests, and ResponseWriters
- Using structs and closures for stateful handlers
- Validating input for Go structs and user inputs
- Rendering and content negotiation
- Implementing and using middleware
- Building a reverse proxy application
- Exporting GRPC as a JSON API
- Testing
- Parallelism and Concurrency
- Distributed Systems
- Reactive Programming and Data Streams
- Serverless Programming
- Performance Improvements, Tips, and Tricks
Product information
- Title: Go Cookbook
- Author(s):
- Release date: June 2017
- Publisher(s): Packt Publishing
- ISBN: 9781783286836
You might also like
book
Go Cookbook
Go is an increasingly popular language for programming everything from web applications to distributed network services. …
book
Kubernetes Cookbook, 2nd Edition
Learn how to automate and manage your containers and reduce the overall operation burden on your …
book
AWS Cookbook
This practical guide provides over 70 self-contained recipes to help you creatively solve common AWS challenges …
book
Kubernetes Cookbook
Kubernetes is becoming the de-facto standard for container orchestration and distributed applications management across a microservices …