<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by JOe CHávez on Medium]]></title>
        <description><![CDATA[Stories by JOe CHávez on Medium]]></description>
        <link>https://medium.com/@izenme?source=rss-52c7aa4e4329------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*NTHmgNpl10Yw6rSQ.jpg</url>
            <title>Stories by JOe CHávez on Medium</title>
            <link>https://medium.com/@izenme?source=rss-52c7aa4e4329------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 01:38:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@izenme/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Or learning a new language — Golang is my latest endeavor to keep my programming skills sharp.]]></title>
            <link>https://medium.com/@izenme/or-learning-a-new-language-golang-is-my-latest-endeavor-to-keep-my-programming-skills-sharp-5f382e81b819?source=rss-52c7aa4e4329------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f382e81b819</guid>
            <category><![CDATA[heroku]]></category>
            <category><![CDATA[slack]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[JOe CHávez]]></dc:creator>
            <pubDate>Mon, 02 May 2016 14:11:02 GMT</pubDate>
            <atom:updated>2016-05-02T14:11:02.842Z</atom:updated>
            <content:encoded><![CDATA[<p>Or learning a new language — <a href="https://golang.org/">Golang</a> is my latest endeavor to keep my programming skills sharp. At the last <a href="http://www.meetup.com/dev-reno/events/228534062/">Reno Developer</a> meetup <a href="https://devreno.slack.com/messages/meetings/team/spot/">Spot</a> presented on <a href="https://golang.org/">Golang</a> and that inspired me to use Go to implement a Slack custom integration for the <a href="https://devreno.slack.com/messages/meetings/">devreno</a> Slack team. The <a href="http://www.meetup.com/dev-reno/events/228534062/">Reno Developer</a> meetup recently received sponsorship from <a href="https://www.jetbrains.com/products.html">JetBrains</a> and one of the perks is we are provided with one license key per month to giveaway to members. Armed with newly acquired knowledge I set out to build a Slack integration in Go that allow any team member to run a <a href="https://api.slack.com/slash-commands">slash command</a> and see if they have won a prize.</p><h3>Slash Commands</h3><p>The name of the command is “raffl” and typing /raffl in any Slack channel:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/0*NSrnSpxAVp0tsUlG." /></figure><p>will display the command, press enter one to focus the command, press enter again to run the command. One of three things will happen:</p><p>You win a prize</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/0*pIJhoDQFYAiF8pY8." /></figure><p>You don’t win a prize</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/0*TbAINtAzP2Wjgs60." /></figure><p>You’ve already won a prize and thus cannot win another</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/0*p1FDSZBKIxc0D7W5." /></figure><p>What are the odds? Currently there are 2 prizes, in the form of JetBrains license keys, and there are 100 members of the devreno Slack team. So your chances are 1 in 100 every time you run /raffl in any Slack channel.</p><h3>Technical Details</h3><h3>Programming in Go</h3><p>Overall Go is easy to pick up assuming:</p><ul><li>You’ve programmed in a C like language</li><li>Are familiar with a managed language</li><li>Enjoy using the command line</li><li>Willing to learn several helper utilities to augment your Go experience</li></ul><p>I opted to also use the <a href="https://github.com/go-lang-plugin-org/go-lang-idea-plugin">Go plugin</a> for <a href="https://www.jetbrains.com/idea/">IntelliJ</a> (both are free!) which provides an integration in a familiar IDE. I found the move and rename refactorting support invaluable as I started to spread my wings with this project.</p><p>I also selected the <a href="https://github.com/boltdb/bolt">Go BoltDB</a> to persist the app data over the lifetime of use in a deployment.</p><h3>Slack &amp; Go</h3><p>The Slack integration consists of a <a href="https://api.slack.com/slash-commands">Slash Command</a> and an <a href="https://api.slack.com/outgoing-webhooks">Outgoing Webhook</a>. This mainly because Slack expects a Slash command to run in less than 3000ms and will report a warning message back to the user if it takes longer. I forked this <a href="https://github.com/trinchan/slackbot">Slackbot</a> framework for use as a starting point. Plenty of details in the docs for the framework and very well written. The basic flow is:</p><ul><li>User types “/raffl” in any Slack channel</li><li>A call is made from Slack to a service running on a remote server (in this case hosted on Heroku)</li><li>The Slash command is processed immediately and if necessary a deferred command is invoke in Go to run additional logic</li><li>Deferred commands are invoked via a <a href="https://github.com/a8m/go-lang-cheat-sheet#goroutines">Goroutine</a> and the response is continued in via Direct Message from @slackbot.</li></ul><p>I choose Direct Message for the response target to keep the details of a prize win/loss secret to the requester.</p><p>The two main Go files for running this logic are:</p><ul><li>Controller: <a href="https://github.com/gitizenme/slackbot/blob/master/robots/raffl/raffl.go">Raffle.go</a> main Slack integration</li><li>Model: <a href="https://github.com/gitizenme/slackbot/blob/master/robots/raffl/db/prize.go">Prize.go</a>. contains logic to interact with BoltDB to manage the Prize data store</li></ul><p>Be gentle if you review the code, I’m sure there is room for improvement in my use of Go.</p><h3>Running Go in Slack</h3><p>I selected Heroku to run the Go service that use invoked from Slack when “/raffle” is run by a user. I found <a href="http://mmcgrana.github.io/2012/09/getting-started-with-go-on-heroku.html">Getting Started With Go on Heroku</a> and the <a href="https://devcenter.heroku.com/articles/getting-started-with-go#introduction">Go tutorial from Heroku</a> (somewhat) useful.</p><h3>Resources</h3><ul><li>Raffle on Github: <a href="https://github.com/gitizenme/slackbot/tree/master/robots/raffl">https://github.com/gitizenme/slackbot/tree/master/robots/raffl</a></li><li>Forked from: <a href="https://github.com/trinchan/slackbot">https://github.com/trinchan/slackbot</a></li><li>Golang Cheatsheet: <a href="https://github.com/a8m/go-lang-cheat-sheet">https://github.com/a8m/go-lang-cheat-sheet</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f382e81b819" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>