Issue Consider the following example: package main import ( "fmt" "time" ) func main() { ticker := time.NewTicker(2 * time.Second) done := make(chan bool) defer func() { fmt.Println("exiting..") done <- true close(done) }() go func(ticker *time.Ticker, done chan bool) {
Continue readingTag: channels
Why is "Greetings done" getting printed before "Bonjour" in the below example of goroutines and channels?
Issue In the below example, Why is "Greetings done" getting printed before "Bonjour" ? Shouldn’t the sender routine wait until receiver routine receives the value in channel ? package main import ( "fmt" ) func greetings(c chan string) { fmt.Println(<-c)
Continue readingHow can I explicitly empty a channel?
Issue The short version: Is there a way to empty a go channel without recreating it, or looping through it? The why: I’m using two channels to send and receive data, and I have an extra channel to signal that
Continue readingClarification on Go channels tutorial from some missing word or words
Issue This page on a Go Tutorial about channels seems to be missing a word(s) or was just not edited. I can’t tell what it is supposed to say about sending and receiving through channels. By default, sends and receives
Continue readingUnable to loop through golang dynamic channels
Issue I want to loop through the menu’s options. However, it stops at the first option, since the select without "default:" is blocking and it does not know more options will appear dynamically. Bellow is the broken code: package main
Continue readingUsing a GoLang Routine to Return to Multiple Threads
Issue I am building an API that can queue up requests to GET an external website and subsequently perform some work by interacting with that API. I am trying to figure out how to avoid duplicate simultaneous go routines. That
Continue readingGo: Performance Hit of Waiting for Multiple Channels
Issue I discovered something today that threw me for a bit of a loop, and I wanted to run it by the community to see if I’m missing something, or perhaps just designing things poorly. Use case: I have an
Continue readingGetting values inside an unmarshalled interface
Issue I have a websocket client that receives multiple data types. A function unmarshals json received from the server into different structs depending on the data received. The struct is then returned as an interface through a channel to my
Continue readinggetting channel value from a webscoket client
Issue I’m running a websocket client and want to pass the response(s) from the client to a channel that i can work with in my main file. Currently, the channel just returns a nil value once and then nothing else.
Continue readingSending to channel doesn't happen if select has default
Issue I am working on a personal project that will run on a Raspberry Pi with some sensors attached to it. The function that read from the sensors and the function that handle the socket connection are executed in different
Continue reading