Go Select and Channels

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Introduction

The select keyword provides an easy method to work with channels and perform more advanced tasks. It is frequently used for a number of purposes: - Handling timeouts. - When there are multiple channels to read from, the select will randomly read from one channel which has data. - Providing an easy way to define what happens if no data is available on a channel.

Syntax

  • select {}
  • select { case true: }
  • select { case incomingData := <-someChannel: }
  • select { default: }


Got any Go Question?