I was going through an example of a TCP server. They defined a function and called it with:
go handleRequest(conn)
I thought it was weird seeing the go
keyword, so I tried it without:
handleRequest(conn)
To my surprise, this worked!
go
keyword at all?go
starts a goroutine, which is managed by golang
run-time.
It can either run on the current OS thread, or it can run on a different OS thread automatically.
You can refer to basic golang
documents for this, for example, one item in Google search keyword goroutine
is golang concurrency.
When you use the Go keyword before a func ure making that func run into a goRoutine, is like a Java Thread, and is the go way for concurrency, more info here. Good Luck