Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Goroutines - What, Why and How?

Goroutines - What, Why and How?

Slides for the talk I gave at the inauguratory session for Golang Gurgaon meetup at Grofers headquarters.

Avatar for Alkesh Srivastava

Alkesh Srivastava

July 21, 2018

More Decks by Alkesh Srivastava

Other Decks in Programming

Transcript

  1. Hello! I am Alkesh Srivastava, a machine learning engineer and

    a Go enthusiast I’m here to help you understand the fundamentals of goroutines You can find me at @_alkesh_
  2. first(“Wait for me”) //first starts, and we wait second() go

    first(“Proceed without me”) //first starts second() //no need to wait for first
  3. I need to worry about the performance, latent deadlocks, race

    conditions etc. while developing concurrent applications Java programmer
  4. I need to worry about the callback spaghetti, not getting

    callback, getting duplicate callbacks, code readability etc. NodeJS programmer
  5. package main import ( "fmt" "time" ) func hello() {

    fmt.Println("Hi, I'm a goroutine!") } func main() { go hello() time.Sleep(1 * time.Second) fmt.Println("Inside main function") }