Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hands-On Full Stack Development with Go

You're reading from   Hands-On Full Stack Development with Go Build full stack web applications with Go, React, Gin, and GopherJS

Arrow left icon
Product type Paperback
Published in Mar 2019
Publisher Packt
ISBN-13 9781789130751
Length 324 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Mina Andrawos Mina Andrawos
Author Profile Icon Mina Andrawos
Mina Andrawos
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Section 1: The Go Language FREE CHAPTER
2. Welcome to Full Stack Go 3. Building Blocks of the Go Language 4. Go Concurrency 5. Section 2: The Frontend
6. Frontend with React.js 7. Building a Frontend for GoMusic 8. Section 3: Web APIs and Middleware in Go
9. RESTful Web APIs in Go with the Gin Framework 10. Advanced Web Go Applications with Gin and React 11. Testing and Benchmarking Your Web API 12. Introduction to Isomorphic Go with GopherJS 13. Where to Go from Here? 14. Other Books You May Enjoy

The sync package

The last topic we will cover in this chapter is the sync package. The sync package is what you will use when you absolutely need to create a lock-in Go. Even though we mentioned that Go prefers the use of channels to communicate data between goroutines, there are cases where a lock or a mutual exclusion object (mutex) is unavoidable. An example of a scenario where locks are utilized in Go's standard package is the http package, where a lock is used to protect the set of listeners to a particular http server object. This set of listeners can be accessed from numerous goroutines so that they get protected by a mutex.

The word mutex, in the world of computer programming, refers to an object that allows multiple threads to access the same resource (such as shared memory). Mutex is so named because it allows only one thread to access data at one time.

The workflow...

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