{"id":100,"date":"2017-08-20T17:58:27","date_gmt":"2017-08-20T21:58:27","guid":{"rendered":"https:\/\/dvdmuckle.xyz\/?p=100"},"modified":"2017-10-13T12:23:04","modified_gmt":"2017-10-13T16:23:04","slug":"learning-go-fun-profit","status":"publish","type":"post","link":"https:\/\/dvdmuckle.xyz\/index.php\/2017\/08\/20\/learning-go-fun-profit\/","title":{"rendered":"Learning Go for Fun and Profit"},"content":{"rendered":"<p>Okay, maybe no actual profit other than knowledge. But lots of fun!<\/p>\n<p><!--more--><\/p>\n<p>One of the perks of knowing C is being able to learn a lot of other languages without having to deviate much from the &#8220;C formula.&#8221; \u00a0It wasn&#8217;t for a while that a proper &#8220;sequel&#8221; to C came out. Go, or golang, was created by Ken Thompson, of UNIX and C fame, and some folks at Google. It&#8217;s basically C 2.0 with a package manager. Which is actually pretty awesome! Not only is it a simple language, using and getting libraries is a breeze. Once you get started, it&#8217;s incredibly easy to start building off of other Go libraries, or creating your own thing for others to use.<\/p>\n<p>So, how did I learn Go? Well, by virtue of knowing C, I already knew most basic things. Did that stop me from googling everything? Nope! For example, if you use a function from another library, say, from <code>fmt<\/code>, you have to capitalize the function, so you would do <code>fmt.Sprintf<\/code>. This is a little different compared to C, where it&#8217;s for the most part case insensitive. There are also multi line strings, some other odd formatting quirks, and neat tricks in terms of variable creation. My favorite thing about Go, and the first thing you learn, is short variable assignment and implicit typing. No more must you specify that 1 is an integer! Just say <code>x := 1<\/code>. Of course there are cases where you might want to specify <code>x<\/code> being, say, a float with a value of 1, or say that <code>y<\/code> has a string value of <code>true<\/code>\u00a0.<\/p>\n<p>Most of my learning was done working on my friend&#8217;s project <a href=\"https:\/\/github.com\/davidscholberg\/irkbot\">Irkbot.<\/a>\u00a0Irkbot is a modular IRC bot written in Go using the go-ircevent library. Because it&#8217;s modular, it&#8217;s very easy to write new features. The first feature I did was the <a href=\"https:\/\/github.com\/dvdmuckle\/irkbot\/blob\/master\/lib\/module\/interject.go\">@interject <\/a>command, which simply prints out the popular Linux\/GNU copypasta with whatever comes after the command, otherwise defaulting to Linux. It took me&#8230; Much longer than it should have to do something this simple, but I got it eventually.\u00a0This also gave me some experience coding for someone else. Most work I do is either for myself or a grade, so I rarely get to change code based on feedback. It&#8217;s an interesting process, and it&#8217;s cool to see how other people format their code.<\/p>\n<p>The next feature I did was <a href=\"https:\/\/github.com\/dvdmuckle\/irkbot\/blob\/master\/lib\/module\/xkcd.go\">@xkcd<\/a>, a command that searches for pertinent xkcd comics based on the search term. To do this, I used\u00a0<a href=\"https:\/\/relevantxkcd.appspot.com\">https:\/\/relevantxkcd.appspot.com<\/a> as a backend, and the go-xkcd library to match comic numbers to comic names. This took a lot more work because I&#8217;d never done anything with HTTP requests like this before.<\/p>\n<p>The most recent feature I did was <a href=\"https:\/\/github.com\/dvdmuckle\/irkbot\/blob\/master\/lib\/module\/doom.go\">@doom<\/a>, which leverages the incredibly interesting <a href=\"https:\/\/github.com\/jeff-1amstudios\/restful-doom\">RESTful Doom<\/a> to play Doom! This was a whole bunch of fun to do, and it was a blast when it started working. I also tweaked Irkbot&#8217;s configuration to be able to connect to IRC servers that require \/PASS auth, so it can connect to Twitch chat. While this means one can play Doom over Twitch chat, the lag makes it almost impossible to actually accomplish anything. I&#8217;d love to test this with a lot more people at some point, so who knows.<\/p>\n<p>So far I&#8217;m really liking Go, and I haven&#8217;t found any issues with it yet. I have some plans in the future for extending Irkbot&#8217;s functionality, and to even create something completely new that will be used in conjunction with the ELK stack. Stay tuned on that! Or maybe keep your eye on my new <a href=\"https:\/\/labs.dvdmuckle.xyz\">lab<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Okay, maybe no actual profit other than knowledge. But lots of fun!<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[8],"tags":[],"class_list":["post-100","post","type-post","status-publish","format-standard","hentry","category-projects"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Learning Go for Fun and Profit - dvdmuckle<\/title>\n<meta name=\"description\" content=\"Go is pretty neat. Jumping right into it by contributing to a project is even cooler.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/dvdmuckle.xyz\/index.php\/2017\/08\/20\/learning-go-fun-profit\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Learning Go for Fun and Profit - dvdmuckle\" \/>\n<meta property=\"og:description\" content=\"Go is pretty neat. Jumping right into it by contributing to a project is even cooler.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dvdmuckle.xyz\/index.php\/2017\/08\/20\/learning-go-fun-profit\/\" \/>\n<meta property=\"og:site_name\" content=\"dvdmuckle\" \/>\n<meta property=\"article:published_time\" content=\"2017-08-20T21:58:27+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-10-13T16:23:04+00:00\" \/>\n<meta name=\"author\" content=\"dvdmuckle\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@dvdmuckle\" \/>\n<meta name=\"twitter:site\" content=\"@dvdmuckle\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"dvdmuckle\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/dvdmuckle.xyz\\\/index.php\\\/2017\\\/08\\\/20\\\/learning-go-fun-profit\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/dvdmuckle.xyz\\\/index.php\\\/2017\\\/08\\\/20\\\/learning-go-fun-profit\\\/\"},\"author\":{\"name\":\"dvdmuckle\",\"@id\":\"https:\\\/\\\/dvdmuckle.xyz\\\/#\\\/schema\\\/person\\\/d4be68025c7bdd8e737dc5f57520eeae\"},\"headline\":\"Learning Go for Fun and Profit\",\"datePublished\":\"2017-08-20T21:58:27+00:00\",\"dateModified\":\"2017-10-13T16:23:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/dvdmuckle.xyz\\\/index.php\\\/2017\\\/08\\\/20\\\/learning-go-fun-profit\\\/\"},\"wordCount\":604,\"commentCount\":0,\"articleSection\":[\"Projects\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/dvdmuckle.xyz\\\/index.php\\\/2017\\\/08\\\/20\\\/learning-go-fun-profit\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/dvdmuckle.xyz\\\/index.php\\\/2017\\\/08\\\/20\\\/learning-go-fun-profit\\\/\",\"url\":\"https:\\\/\\\/dvdmuckle.xyz\\\/index.php\\\/2017\\\/08\\\/20\\\/learning-go-fun-profit\\\/\",\"name\":\"Learning Go for Fun and Profit - dvdmuckle\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/dvdmuckle.xyz\\\/#website\"},\"datePublished\":\"2017-08-20T21:58:27+00:00\",\"dateModified\":\"2017-10-13T16:23:04+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/dvdmuckle.xyz\\\/#\\\/schema\\\/person\\\/d4be68025c7bdd8e737dc5f57520eeae\"},\"description\":\"Go is pretty neat. Jumping right into it by contributing to a project is even cooler.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/dvdmuckle.xyz\\\/index.php\\\/2017\\\/08\\\/20\\\/learning-go-fun-profit\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/dvdmuckle.xyz\\\/index.php\\\/2017\\\/08\\\/20\\\/learning-go-fun-profit\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/dvdmuckle.xyz\\\/index.php\\\/2017\\\/08\\\/20\\\/learning-go-fun-profit\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/dvdmuckle.xyz\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Learning Go for Fun and Profit\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/dvdmuckle.xyz\\\/#website\",\"url\":\"https:\\\/\\\/dvdmuckle.xyz\\\/\",\"name\":\"dvdmuckle\",\"description\":\"Just another DevOps engineer\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/dvdmuckle.xyz\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/dvdmuckle.xyz\\\/#\\\/schema\\\/person\\\/d4be68025c7bdd8e737dc5f57520eeae\",\"name\":\"dvdmuckle\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a9bf2c785e17bce6592bac81033a7b44e2e3a6f9ce194ef3f99676804be5da2f?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a9bf2c785e17bce6592bac81033a7b44e2e3a6f9ce194ef3f99676804be5da2f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a9bf2c785e17bce6592bac81033a7b44e2e3a6f9ce194ef3f99676804be5da2f?s=96&d=mm&r=g\",\"caption\":\"dvdmuckle\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Learning Go for Fun and Profit - dvdmuckle","description":"Go is pretty neat. Jumping right into it by contributing to a project is even cooler.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/dvdmuckle.xyz\/index.php\/2017\/08\/20\/learning-go-fun-profit\/","og_locale":"en_US","og_type":"article","og_title":"Learning Go for Fun and Profit - dvdmuckle","og_description":"Go is pretty neat. Jumping right into it by contributing to a project is even cooler.","og_url":"https:\/\/dvdmuckle.xyz\/index.php\/2017\/08\/20\/learning-go-fun-profit\/","og_site_name":"dvdmuckle","article_published_time":"2017-08-20T21:58:27+00:00","article_modified_time":"2017-10-13T16:23:04+00:00","author":"dvdmuckle","twitter_card":"summary_large_image","twitter_creator":"@dvdmuckle","twitter_site":"@dvdmuckle","twitter_misc":{"Written by":"dvdmuckle","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/dvdmuckle.xyz\/index.php\/2017\/08\/20\/learning-go-fun-profit\/#article","isPartOf":{"@id":"https:\/\/dvdmuckle.xyz\/index.php\/2017\/08\/20\/learning-go-fun-profit\/"},"author":{"name":"dvdmuckle","@id":"https:\/\/dvdmuckle.xyz\/#\/schema\/person\/d4be68025c7bdd8e737dc5f57520eeae"},"headline":"Learning Go for Fun and Profit","datePublished":"2017-08-20T21:58:27+00:00","dateModified":"2017-10-13T16:23:04+00:00","mainEntityOfPage":{"@id":"https:\/\/dvdmuckle.xyz\/index.php\/2017\/08\/20\/learning-go-fun-profit\/"},"wordCount":604,"commentCount":0,"articleSection":["Projects"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/dvdmuckle.xyz\/index.php\/2017\/08\/20\/learning-go-fun-profit\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/dvdmuckle.xyz\/index.php\/2017\/08\/20\/learning-go-fun-profit\/","url":"https:\/\/dvdmuckle.xyz\/index.php\/2017\/08\/20\/learning-go-fun-profit\/","name":"Learning Go for Fun and Profit - dvdmuckle","isPartOf":{"@id":"https:\/\/dvdmuckle.xyz\/#website"},"datePublished":"2017-08-20T21:58:27+00:00","dateModified":"2017-10-13T16:23:04+00:00","author":{"@id":"https:\/\/dvdmuckle.xyz\/#\/schema\/person\/d4be68025c7bdd8e737dc5f57520eeae"},"description":"Go is pretty neat. Jumping right into it by contributing to a project is even cooler.","breadcrumb":{"@id":"https:\/\/dvdmuckle.xyz\/index.php\/2017\/08\/20\/learning-go-fun-profit\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dvdmuckle.xyz\/index.php\/2017\/08\/20\/learning-go-fun-profit\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/dvdmuckle.xyz\/index.php\/2017\/08\/20\/learning-go-fun-profit\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dvdmuckle.xyz\/"},{"@type":"ListItem","position":2,"name":"Learning Go for Fun and Profit"}]},{"@type":"WebSite","@id":"https:\/\/dvdmuckle.xyz\/#website","url":"https:\/\/dvdmuckle.xyz\/","name":"dvdmuckle","description":"Just another DevOps engineer","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dvdmuckle.xyz\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/dvdmuckle.xyz\/#\/schema\/person\/d4be68025c7bdd8e737dc5f57520eeae","name":"dvdmuckle","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/a9bf2c785e17bce6592bac81033a7b44e2e3a6f9ce194ef3f99676804be5da2f?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/a9bf2c785e17bce6592bac81033a7b44e2e3a6f9ce194ef3f99676804be5da2f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a9bf2c785e17bce6592bac81033a7b44e2e3a6f9ce194ef3f99676804be5da2f?s=96&d=mm&r=g","caption":"dvdmuckle"}}]}},"_links":{"self":[{"href":"https:\/\/dvdmuckle.xyz\/index.php\/wp-json\/wp\/v2\/posts\/100","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dvdmuckle.xyz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dvdmuckle.xyz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dvdmuckle.xyz\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dvdmuckle.xyz\/index.php\/wp-json\/wp\/v2\/comments?post=100"}],"version-history":[{"count":6,"href":"https:\/\/dvdmuckle.xyz\/index.php\/wp-json\/wp\/v2\/posts\/100\/revisions"}],"predecessor-version":[{"id":129,"href":"https:\/\/dvdmuckle.xyz\/index.php\/wp-json\/wp\/v2\/posts\/100\/revisions\/129"}],"wp:attachment":[{"href":"https:\/\/dvdmuckle.xyz\/index.php\/wp-json\/wp\/v2\/media?parent=100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dvdmuckle.xyz\/index.php\/wp-json\/wp\/v2\/categories?post=100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dvdmuckle.xyz\/index.php\/wp-json\/wp\/v2\/tags?post=100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}