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?Concurrency is not well documented in the go spec and it is one of the most powerful features of the language, the go keyword is the starting point when you are building concurrent software and not procedural software in go.
Golang make() is a built-in slice function used to create a slice. The make() function takes three arguments: type, length, and capacity, and returns the slice. To create dynamically sized arrays, use the make() function. The make() function allocates a zeroed array and returns a slice that refers to that array.
Working with Parameters In Go, you must specify the data type for each parameter. Let's create a program that repeats a word a specified number of times. It will take a string parameter called word and an int parameter called reps for the number of times to repeat the word.
The Go goto statement is a jump statement which is used to transfer the control to other parts of the program. In goto statement, there must be a label. We use label to transfer the control of the program. Go Goto Statement Example: package main.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With