Learning Go
already familiar with Go, but there is always more to learn. This is a collection of notes on learning Go.
Table of Contents #
- 0x0000: Channeling
- 0xx0001: Concurrency
- 0x0002: Error Handling
- 0x0003: Interfaces
- 0x0004: Packages
- 0x0005: Pointers
- 0x0006: Slices
Channeling #
Channels are a way to communicate between goroutines. They are typed, so you can only send and receive the type that the channel is defined with. Channels can be buffered or unbuffered. Unbuffered channels block until the data is received. Buffered channels can hold a certain number of values before blocking.
package main
import "fmt"
func main() {
ch := make(chan int, 1)
ch <- 42
fmt.Println(<-ch)
}