Go Cookbook

Bridge the gap between basic understanding of Go and use of its advanced features
Preview in Mapt

Go Cookbook

Aaron Torres

3 customer reviews
Bridge the gap between basic understanding of Go and use of its advanced features
Mapt Subscription
FREE
$29.99/m after trial
eBook
$25.20
RRP $35.99
Save 29%
Print + eBook
$44.99
RRP $44.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$25.20
$44.99
$29.99p/m after trial
RRP $35.99
RRP $44.99
Subscription
eBook
Print + eBook
Start 30 Day Trial

Frequently bought together


Go Cookbook Book Cover
Go Cookbook
$ 35.99
$ 25.20
OpenGL 4 Shading Language Cookbook, Second Edition Book Cover
OpenGL 4 Shading Language Cookbook, Second Edition
$ 32.99
$ 23.10
Buy 2 for $35.00
Save $33.98
Add to Cart
Subscribe and access every Packt eBook & Video.
 
  • 5,000+ eBooks & Videos
  • 50+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 

Book Details

ISBN 139781783286836
Paperback400 pages

Book Description

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.

Table of Contents

Chapter 1: I/O and File Systems
Introduction
Using the common I/O interfaces
Using the bytes and strings packages
Working with directories and files
Working with the CSV format
Working with temporary files
Working with text/template and HTML/templates
Chapter 2: Command-Line Tools
Introduction
Using command-line flags
Using command-line arguments
Reading and setting environment variables
Configuration using TOML, YAML, and JSON
Working with Unix pipes
Catching and handling signals
An ANSI coloring application
Chapter 3: 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
Chapter 4: 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
Chapter 5: All about Databases and Storage
Introduction
The database/sql package with MySQL
Executing a database transaction interface
Connection pooling, rate limiting, and timeouts for SQL
Working with Redis
Using NoSQL with MongoDB and mgo
Creating storage interfaces for data portability
Chapter 6: 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
Chapter 7: 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
Chapter 8: Testing
Introduction
Mocking using the standard library
Using the Mockgen package
Using table-driven tests to improve coverage
Using third-party testing tools
Practical fuzzing
Behavior testing using Go
Chapter 9: Parallelism and Concurrency
Introduction
Using channels and the select statement
Performing async operations with sync.WaitGroup
Using atomic operations and mutex
Using the context package
Executing state management for channels
Using the worker pool design pattern
Using workers to create pipelines
Chapter 10: Distributed Systems
Introduction
Using service discovery with Consul
Implementing basic consensus using Raft
Using containerization with Docker
Orchestration and deployment strategies
Monitoring applications
Collecting metrics
Chapter 11: Reactive Programming and Data Streams
Introduction
Goflow for dataflow programming
Reactive programming with RxGo
Using Kafka with Sarama
Using async producers with Kafka
Connecting Kafka to Goflow
Writing a GraphQL server in Go
Chapter 12: Serverless Programming
Introduction
Go programming on Lambda with Apex
Apex serverless logging and metrics
Google App Engine with Go
Working with Firebase using zabawaba99/firego
Chapter 13: Performance Improvements, Tips, and Tricks
Introduction
Speeding up compilation and testing cycles
Using the pprof tool
Benchmarking and finding bottlenecks
Memory allocation and heap management
Vendoring and project layout
Using fasthttprouter and fasthttp

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

Authors

Table of Contents

Chapter 1: I/O and File Systems
Introduction
Using the common I/O interfaces
Using the bytes and strings packages
Working with directories and files
Working with the CSV format
Working with temporary files
Working with text/template and HTML/templates
Chapter 2: Command-Line Tools
Introduction
Using command-line flags
Using command-line arguments
Reading and setting environment variables
Configuration using TOML, YAML, and JSON
Working with Unix pipes
Catching and handling signals
An ANSI coloring application
Chapter 3: 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
Chapter 4: 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
Chapter 5: All about Databases and Storage
Introduction
The database/sql package with MySQL
Executing a database transaction interface
Connection pooling, rate limiting, and timeouts for SQL
Working with Redis
Using NoSQL with MongoDB and mgo
Creating storage interfaces for data portability
Chapter 6: 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
Chapter 7: 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
Chapter 8: Testing
Introduction
Mocking using the standard library
Using the Mockgen package
Using table-driven tests to improve coverage
Using third-party testing tools
Practical fuzzing
Behavior testing using Go
Chapter 9: Parallelism and Concurrency
Introduction
Using channels and the select statement
Performing async operations with sync.WaitGroup
Using atomic operations and mutex
Using the context package
Executing state management for channels
Using the worker pool design pattern
Using workers to create pipelines
Chapter 10: Distributed Systems
Introduction
Using service discovery with Consul
Implementing basic consensus using Raft
Using containerization with Docker
Orchestration and deployment strategies
Monitoring applications
Collecting metrics
Chapter 11: Reactive Programming and Data Streams
Introduction
Goflow for dataflow programming
Reactive programming with RxGo
Using Kafka with Sarama
Using async producers with Kafka
Connecting Kafka to Goflow
Writing a GraphQL server in Go
Chapter 12: Serverless Programming
Introduction
Go programming on Lambda with Apex
Apex serverless logging and metrics
Google App Engine with Go
Working with Firebase using zabawaba99/firego
Chapter 13: Performance Improvements, Tips, and Tricks
Introduction
Speeding up compilation and testing cycles
Using the pprof tool
Benchmarking and finding bottlenecks
Memory allocation and heap management
Vendoring and project layout
Using fasthttprouter and fasthttp

Book Details

ISBN 139781783286836
Paperback400 pages
Read More
From 3 reviews

Read More Reviews

Recommended for You

Building Microservices with Go Book Cover
Building Microservices with Go
$ 35.99
$ 25.20
Learning Go Web Development Book Cover
Learning Go Web Development
$ 23.99
$ 16.80
Go Design Patterns Book Cover
Go Design Patterns
$ 39.99
$ 28.00
Mastering Go Web Services Book Cover
Mastering Go Web Services
$ 39.99
$ 28.00
Go Programming Blueprints Book Cover
Go Programming Blueprints
$ 29.99
$ 21.00
OpenGL 4 Shading Language Cookbook, Second Edition Book Cover
OpenGL 4 Shading Language Cookbook, Second Edition
$ 32.99
$ 23.10