From: Javier Sancho Date: Wed, 10 Jan 2018 16:18:24 +0000 (+0100) Subject: Midgaard Bot post corrections X-Git-Url: https://git.jsancho.org/?p=blog.git;a=commitdiff_plain;h=471c18b13cd29667b20ed8f1ca17a41da344dac6 Midgaard Bot post corrections --- diff --git a/posts/20171227-midgaard_bot.html b/posts/20171227-midgaard_bot.html index 116dcb0..65aa2d6 100644 --- a/posts/20171227-midgaard_bot.html +++ b/posts/20171227-midgaard_bot.html @@ -2,7 +2,7 @@ title: Midgaard Bot, conneting to a MUD with Telegram date: 2017-12-27 11:51 ---
-

A colleague of mine, Vlad Nicu, is developing a Telegram bot to offer information about cryptocurrencies (price, etc). After talking with him, I had the idea of writing a bot to connect to a MUD (Multi User Dungeon) using Telegram. When I was young, I spent a long time playing with this type of online games and I thought it'd be fun to develop something similar.

+

A colleague of mine, Vlad Nicu, is developing a Telegram bot to offer information about cryptocurrencies (price, etc). After talking with him, I had the idea of writing a bot to connect to a MUD (Multi User Dungeon) using Telegram. When I was young, I spent a lot of time playing with this type of online games and I thought it'd be fun to develop something similar.

I decided to use Golang to practice a little with this language and its goroutines. I think it has a lot of things that could be improved, but, undoubtedly, concurrency is its strongest feature. From my point of view, sometimes people abuse of channels and goroutines. I have seen a lot of examples of problems that could be resolved only with function calls, without all the goroutines system.

@@ -16,7 +16,7 @@ date: 2017-12-27 11:51

When the message is complete, we send it to a specific goroutine that receives messages from open sessions and forwards them to Telegram.

-

During the development, a funny thing happened to me, and that makes me think about how goroutines really work. The goroutine in charge of an open session wrote a message to a channel and, after that, it got suspended. The problem was taht I didn't develop the code to read that channel yet, and Go channels block the execution.

+

During the development, a funny thing happened to me, and that makes me think about how goroutines really work. The goroutine in charge of an open session wrote a message to a channel and, after that, it got suspended. The problem was that I didn't develop the code to read that channel yet, and Go channels block the execution.

I thought Go channels run in a similar way than messages work in Erlang. In Erlang, a process send messages asynchronously, and the execution continues independently. But in Golang is different, channels aren't pipes, are meeting points for goroutines. If you put a message in a channel, you are blocked until another goroutine reads that channel and releases the goroutine that has written that message.