Video:

Goroutines in Go

June 4, 2021

Course Instructor: Elliot Forbes

Hey Gophers! My name is Elliot and I'm the creator of TutorialEdge and I've been working with Go systems for roughly 5 years now.

In this video, we are going to be looking at goroutines in Go and what they are used for.

Overview

package main

import (
	"fmt"
	"time"
)

func HelloWorld(name string) {
	time.Sleep(1 * time.Second)
	fmt.Printf("hello: %s\n", name)
}

func main() {
	go HelloWorld("Elliot")
	fmt.Println("I should be printed first")
	time.Sleep(2 * time.Second)
}

Output

$ go run main.go
I should be printed first
hello: Elliot