Book description
Tackle the trickiest of problems in Go programming with this practical guide
Key Features
- Develop applications for different domains using modern programming techniques
- Tackle common problems when it comes to parallelism, concurrency, and reactive programming in Go
- Work with ready-to-execute code based on the latest version of Go
Book Description
Go (or Golang) is a statically typed programming language developed at Google. Known for its vast standard library, it also provides features such as garbage collection, type safety, dynamic-typing capabilities, and additional built-in types. This book will serve as a reference while implementing Go features to build your own applications.
This Go cookbook helps you put into practice the advanced concepts and libraries that Golang offers. The recipes in the book follow best practices such as documentation, testing, and vendoring with Go modules, as well as performing clean abstractions using interfaces. You'll learn how code works and the common pitfalls to watch out for. The book covers basic type and error handling, and then moves on to explore applications, such as websites, command-line tools, and filesystems, that interact with users. You'll even get to grips with parallelism, distributed systems, and performance tuning.
By the end of the book, you'll be able to use open source code and concepts in Go programming to build enterprise-class applications without any hassle.
What you will learn
- Work with third-party Go projects and modify them for your use
- Write Go code using modern best practices
- Manage your dependencies with the new Go module system
- Solve common problems encountered when dealing with backend systems or DevOps
- Explore the Go standard library and its uses
- Test, profile, and fine-tune Go applications
Who this book is for
If you're a web developer, programmer, or enterprise developer looking for quick solutions to common and not-so-common problems in Go programming, this book is for you. Basic knowledge of the Go language is assumed.
Table of contents
- Title Page
- Copyright and Credits
- Dedication
- About Packt
- Contributors
- Preface
- I/O and Filesystems
- Command-Line Tools
-
Data Conversion and Composition
- Technical requirements
- 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
- Structure tags and basic reflection in Go
- Implementing collections via closures
-
Error Handling in Go
- Technical requirements
- 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
- Network Programming
- All about Databases and Storage
-
Web Clients and APIs
- Technical requirements
- Initializing, storing, and passing http.Client structures
- 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
- Using twitchtv/twirp for RPC
-
Microservices for Applications in Go
- Technical requirements
- Working with web handlers, requests, and ResponseWriter instances
- Using structures and closures for stateful handlers
- Validating input for Go structures and user inputs
- Rendering and content negotiation
- Implementing and using middleware
- Building a reverse proxy application
- Exporting GRPC as a JSON API
- Testing Go Code
- Parallelism and Concurrency
- Distributed Systems
- Reactive Programming and Data Streams
- Serverless Programming
- Performance Improvements, Tips, and Tricks
- Other Books You May Enjoy
Product information
- Title: Go Programming Cookbook - Second Edition
- Author(s):
- Release date: July 2019
- Publisher(s): Packt Publishing
- ISBN: 9781789800982
You might also like
book
Go Systems Programming
Learning the new system’s programming language for all Unix-type systems About This Book Learn how to …
book
Go Standard Library Cookbook
Implement solutions by leveraging the power of the GO standard library and reducing dependency on external …
book
Go Programming Blueprints - Second Edition
Build real-world, production-ready solutions in Go using cutting-edge technology and techniques About This Book Get up …
book
Get Programming with Go
Get Programming with Go introduces you to the powerful Go language without confusing jargon or high-level …