Goroutine is a functionality in Go that allows you to run your code concurrently in your applications. It is like Promise or setTimeout in TypeScript but more efficient.
// Example
package main
func sayHello() {
fmt.Println("Hello there!")
}
func main() {
go sayhello()
go sayHello()
fmt.Println("Main Function")
time.Sleep(1 * time.Second)
}
// Output
/*
Output, in this context, is unpredictable so the first or the second call might be first. However, a call that outputs `Main Function` will not be blocked and will be displayed as the first one. This is because GoRoutine doesn't block the main _thread_.
*/