Skip to content

Comment on Clojure core.async and Go: A Code Comparison

Comments

Small bug irrelevant to the main point of the article: The very last golang example has a leak. If the timeout does occur, main will exit after a timeout and the spawned go routine will hang on the channel push.

I think the easiest fix is to make the channel buffered. "make(chan string)" => "make(chan string, 1)" Not sure if there is a more idiomatic golang way to accomplish this.

Once main exits the program does as well, so all other goroutines will be terminated.

True. Leaks don't matter for programs that exit immediately. I was pointing it out because it is often relevant when using the timeout pattern.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.