Tag: channels

  • Goroutines don’t panic if channel they write to is gone

    Couple of months ago I wrote an article about error handling in concurrent Go programs. One concern I had about it was if other goroutines would panic if some goroutine produces an error value which causes return from function when the channel is iterated with range construct. So I made another program that mimics scenario.…

  • Error handling in concurrent programs in Golang

    Error handling in concurrent programs in Go consists of little more work than if err != nil { return err } because the return value doesn’t reach intended receiver (for example in parent function where function was fired as a goroutine using go keyword). Just as we use channel for sending resulting data, we must…

  • Testing concurrent code in Golang

    I wrote a package which tracks certain hashtags on twitter and part of the package is adding and removing hashtag from list of hashtags. Plan is that this can be done from different goroutines hence tracking/untracking is done by putting hashtag in channels. It looks like this: var ( trackChan = make(chan string) untrackChan =…

  • Channels in Go

    Do not communicate by sharing memory; instead, share memory by communicating. Channels are for orchestration, mutexes are for serialization. Go Proverbs – Rob Pike Yesterday I wrote my first project ((It’s URL shorterer, a project which I write in every new programming language I learn.)) in Go which does not use traditional locks when dealing…