Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Go Programming Cookbook

You're reading from   Go Programming Cookbook Over 85 recipes to build modular, readable, and testable Golang applications across various domains

Arrow left icon
Product type Paperback
Published in Jul 2019
Publisher Packt
ISBN-13 9781789800982
Length 434 pages
Edition 2nd Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Aaron Torres Aaron Torres
Author Profile Icon Aaron Torres
Aaron Torres
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Preface 1. I/O and Filesystems FREE CHAPTER 2. Command-Line Tools 3. Data Conversion and Composition 4. Error Handling in Go 5. Network Programming 6. All about Databases and Storage 7. Web Clients and APIs 8. Microservices for Applications in Go 9. Testing Go Code 10. Parallelism and Concurrency 11. Distributed Systems 12. Reactive Programming and Data Streams 13. Serverless Programming 14. Performance Improvements, Tips, and Tricks 15. Other Books You May Enjoy

Executing state management for channels

Channels can be any type in Go. A channel of structs allows you to pass a lot of state with a single message. This recipe will explore the use of channels to pass around complex request structures and return their results in complex response structs.

In the next recipe, Using the worker pool design pattern, the value of this becomes even more apparent as you can create general purpose workers capable of performing a variety of tasks.

How to do it...

These steps cover writing and running your application:

  1. From your Terminal or console application,createa new directory called~/projects/go-programming-cookbook/chapter10/stateand navigate to it.
  2. Run the following command:
          $ go mod init github.com/PacktPublishing/Go-Programming-Cookbook-Second-Edition/chapter10/state

You should see a file calledgo.modthat contains the following content:

module...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image