Byte arrays and Channels

Hi folks and a Happy new Year! Today, I would like to show you some interesting things you can do with channels. Consider the following simple example. package main import "fmt" func main() { generatedPassword := make(chan int, 100) correctPassword := make(chan int) defer close(generatedPassword) defer close(correctPassword) go passwordIncrement(generatedPassword) go checkPassword(generatedPassword, correctPassword) pass := <-correctPassword fmt.Println(pass) } func checkPassword(input <-chan int, output chan<- int) { for { p := <-input //Introduce lengthy operation here // time....

January 1, 2016 · 4 min · hannibal