Learning Go

Go, Language, Notes

already familiar with Go, but there is always more to learn. This is a collection of notes on learning Go.

Table of Contents #

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)
}