Learning Golang: Introduction to Concurrency Patterns, goroutines and channels
Mario Carrion
View ChannelAbout
Welcome👋🏼 Hello! My name is Mario, and I am a Hands-on Software Architect and Lead Backend Engineer with decades of professional experience building all kinds of software, such as on-premise Automation Systems, Linux Accessibility Desktop Applications, Cloud Governance and Compliance Systems, Media Streaming Services, and Highly Scalable Distributed Cloud-based Advertising Systems. I post a new video every other Monday at 09:00 AM Eastern Time. The content I produce includes what I've learned while working for small startups and large companies and the processes I've followed for successfully delivering complex enterprise systems from start to end. Subscribe if you like Software Development, Software Architecture, and Systems Design... and of course, Go! Keep it up. Don't give up!
Latest Posts
Video Description
Welcome! Let's learn about Go/Golang Concurrency Patterns, but first let's learn about concurrency in Go/Golang, including goroutines, channels and the different keywords needed: like close, range and select. * What is a goroutine? It is lightweight thread managed by the Go/Golang runtime, independently executed function that has its own call stack. * What is a channel? Is a mechanism through which we can send and receive values, it uses the arrow operator which indicates data flow. By default sender and receiver will block if the other side is not ready * What is a buffered channel? It's a type of buffer that has a length. Sending to a buffered channel will block if it is full and receiving from a buffered channel will only block when it's empty. * What else can we do with channels? There are 3 new keywords applicable to channels: "close", "select" and "range": * "close" allows closing the channel, this means we can't receive or send values to it. * "selects" allows to receive messages from multiple channels via "cases", it's like a "switch", it also supports a "default" value. * "range" is similar to the keyword used when looping through slices/arrays; but in this cases it will continuously receive values from the channel until it gets closed. Recall this is the "Introduction to Concurrency Patterns in Go/Golang", in future episodes I will describe concrete patterns to use when building concurrent programs. --- RELEVANT LINKS * Previous episode: "Learning Golang: Interface Types - Part 2 (empty interface, type assertion and type switches)" https://youtu.be/m14ob5dCLag * Example code: https://github.com/MarioCarrion/videos/tree/8b70c807d63b854cde4dcbf1a1111b856a449cd5/2021/08/12/introductions-concurrency-patterns * Playlist "Software Architecture in Go": https://www.youtube.com/playlist?list=PL7yAAGMOat_GCd12Lrv_evJ3Zhv1dl8B- * Playlist "Learning Go": https://www.youtube.com/playlist?list=PL7yAAGMOat_F7bOImcjx4ZnCtfyNEqzCy * Playlist "Building Microservices in Go": https://www.youtube.com/playlist?list=PL7yAAGMOat_Fn8sAXIk0WyBfK_sT1pohu * Playlist "GoTools and Packages": https://www.youtube.com/playlist?list=PL7yAAGMOat_HEEOvH99agDs_5g51A0Ls3 * Playlist "Testing in Go": https://www.youtube.com/playlist?list=PL7yAAGMOat_HSeW4zF0uRL9EaHadE4ZZq 00:00 Intro 00:16 What is Concurrency? 00:36 What is Parallelism? 00:46 Analogy: Concurrency 01:53 Analogy: Parallelism 02:20 What is a goroutine in Golang? 02:49 Example: goroutine in Golang 04:03 What is channel in Golang? 05:30 Example 1: channels in Golang 06:40 Example 2: channels and goroutines in Golang 08:35 What is a buffered channel in Golang? 09:56 Example: buffered channels in Golang 11:39 Channels: Close, Select and Range in Golang 12:33 Example: goroutines and channels in Golang 17:12 Conclusion: Introduction to Concurrency Patterns in Golang --- Who am I: Hello👋🏼! I'm Mario, a Hands-on Software Architect and Lead Backend Engineer with more than 16 years of professional experience building all kinds of software including on-premise Industrial Automation Systems, Linux Accessibility Desktop and Browser Components as well as Distributed Advertising Microservices. Every week I will share with you different topics I've learned while working for small startups and large companies including the processes I've followed over the years for successfully delivering complex enterprise systems from start to end. Subscribe if you like Software Development, Software Architecture and Systems Design! Keep it up. Don't give up! https://twitter.com/MarioCarrion https://instagram.com/Mario.Carrion #golang #tutorial #concurrency --- Our affiliate links below Shop our Amazon favorites → https://www.amazon.com/shop/rubycarrion Shop my IG feed on my LIKEtoKNOWit (LTK) page → https://www.liketoknow.it/RubyCarrion Shop Top Deals and Featured Offers at Best Buy → https://bestbuy.7tiv.net/c/2558226/687081/10014 Get a 30 day FREE Trial of Epidemic Sound → https://www.epidemicsound.com/referral/szx441/ Try Amazon Prime 30-day FREE Trial → https://amzn.to/3yf9a0f I love getting Cash Back and think you will too! Join for FREE and get $30 when you spend $30. https://www.rakuten.com/r/RUBYRA132?eeid=28187 --- Our Vlog Channel https://www.youtube.com/c/RubyCarrion/videos
Boost Your Golang Skills
AI-recommended products based on this video

TRAUSI HD Webcam with Microphone, Noise Cancellation, Privacy Cover, Wide-Angle Lens, Auto Light Correction, Plug & Play USB Webcam for Laptop, Desktop, PC, Mac, Zoom, Skype, Streaming (1080P, Black)

TRAUSI 1080P HD Webcam with Microphone, Noise Cancellation, Privacy Cover, Wide-Angle Lens, Auto Light Correction, Plug & Play USB Webcam for Laptop, Desktop, PC, Mac, Zoom, Skype, Streaming Black

10Gtek USB WiFi Adapter, for PC, AC600M USB WiFi Dongle 802.11ac Wireless Network Adapter with Dual Band 2.4GHz/5Ghz for Desktop Laptop Support Windows 10/8/7/XP, MAC OS, Linux etc

1300Mbps Wireless WiFi Adapter, USB3.0 WiFi Dongle 2.4G/5G 802.11AC Network Adapter Receiver with High Gain Antenna for Desktop Laptop PC, Support Windows 11/10/8/8.1/7/Vista/XP, Mac 10.6-10.15

The Sqirl Jam (Jelly, Fruit Butter, and Others) Book

Cozy Corner: Coloring Book for Adults and Kids

Hello, Baby Animals: A Durable High-Contrast Black-and-White Board Book for Newborns and Babies

Little Blue Truck's Halloween: A Fun And Interactive Lift-the-Flap Book For Kids Celebrating Halloween With Little Blue Truck And Friends

Asus Vivobook Go 15 Laptop, 15.6” FHD Display, Intel® Core™ i3-N305 Processor, 4GB RAM, 128GB UFS, Windows 11 Home in S Mode, E1504GA-AS32-CA

ASUS Vivobook Go 12 L210 11.6” Ultra-Thin Laptop, Intel Celeron N4500, 4GB RAM, 64GB eMMC, Windows 11 Home in S Mode Includes 1 Year of Office 365 Personal, L210KA-AS01-CA

Hand Warmers Rechargeable OUTJUT 2 in 1 USB Pocket-Sized Handwarmers Easy to Carry Electric Hand Warmer 3 Heat Settings Hot Hand Gifts for Men Women Go Out for Hiking Camping Sking and Fishing

