<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Golang on Samarthya</title><link>https://samarthya.me/tags/golang/</link><description>Recent content in Golang on Samarthya</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>© Samarthya 2018-2026. All rights reserved.</copyright><lastBuildDate>Mon, 22 Feb 2021 12:00:00 +0000</lastBuildDate><atom:link href="https://samarthya.me/tags/golang/index.xml" rel="self" type="application/rss+xml"/><item><title>GoLang: try-catch</title><link>https://samarthya.me/posts/golang-try-catch/</link><pubDate>Mon, 22 Feb 2021 12:00:00 +0000</pubDate><guid>https://samarthya.me/posts/golang-try-catch/</guid><description>&lt;p&gt;GoLang doesn’t have a try and catch like the popular C++ or Java languages, what it has is &lt;code&gt;panic-recover&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;Non critical errors are returned as normal values and for the critical ones, &lt;code&gt;panic&lt;/code&gt; is used&lt;/p&gt;</description></item><item><title>GoLang: encoding</title><link>https://samarthya.me/posts/golang-encoding/</link><pubDate>Sat, 30 Jan 2021 12:00:00 +0000</pubDate><guid>https://samarthya.me/posts/golang-encoding/</guid><description>&lt;p&gt;Package encoding provide capabilities to convert data to and from byte-level and textual representations.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;encoding/gob&lt;/li&gt;&#10;&lt;li&gt;encoding/json, and&lt;/li&gt;&#10;&lt;li&gt;encoding/xml&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="lead text-neutral-500 dark:text-neutral-400 !mb-9 text-xl"&gt;&#10; The &lt;em&gt;gob&lt;/em&gt; is Go’s format for &lt;em&gt;serializing&lt;/em&gt; and &lt;em&gt;deserializing&lt;/em&gt;. The gob was tailored for communicating between two servers written in Go.&#10;&lt;/div&gt;&#10;&#10;&lt;ul&gt;&#10;&lt;li&gt;Only exported fields are encoded; zero values are not taken into account&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="lead text-neutral-500 dark:text-neutral-400 !mb-9 text-xl"&gt;&#10; Package gob manages streams of gobs – binary values exchanged between an Encoder (transmitter) and a Decoder (receiver).&#10;&lt;/div&gt;&#10;&#10;&#10;&lt;h2 class="relative group"&gt;Format GoB&#10; &lt;div id="format-gob" class="anchor"&gt;&lt;/div&gt;&#10; &#10; &lt;span&#10; class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;&#10; &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#format-gob" aria-label="Anchor"&gt;#&lt;/a&gt;&#10; &lt;/span&gt;&#10; &#10;&lt;/h2&gt;&#10;&lt;p&gt;Let’s create a simple Type &lt;code&gt;Blog&lt;/code&gt; and we will encode and decode it using the gob format.&lt;/p&gt;</description></item><item><title>Race condition</title><link>https://samarthya.me/posts/race-condition/</link><pubDate>Tue, 06 Oct 2020 10:46:18 +0000</pubDate><guid>https://samarthya.me/posts/race-condition/</guid><description>&lt;p&gt;When two processes are executing concurrently, the exact order of execution of instructions is not deterministic. Without explicit synchronization instructions it is difficult to predict the outcome of these concurrent execution of process.&lt;/p&gt;</description></item><item><title>Dockeriz'd service</title><link>https://samarthya.me/posts/dockerizd-service/</link><pubDate>Thu, 13 Aug 2020 05:51:34 +0000</pubDate><guid>https://samarthya.me/posts/dockerizd-service/</guid><description>&lt;p&gt;Someone asked me to define a simple docker pod for the service I wrote in GOLang &lt;a href="https://samarthya.me/posts/go-webservice-postget/" &gt;here.&lt;/a&gt; I completely forgot about it, till today.&lt;/p&gt;&#10;&lt;p&gt;So here is my first attempt at getting a docker image for the service.&lt;/p&gt;</description></item><item><title>Go: WebService [POST][GET]</title><link>https://samarthya.me/posts/go-webservice-postget/</link><pubDate>Wed, 20 May 2020 08:38:20 +0000</pubDate><guid>https://samarthya.me/posts/go-webservice-postget/</guid><description>&lt;h2 class="relative group"&gt;GOLANG&#10; &lt;div id="golang" class="anchor"&gt;&lt;/div&gt;&#10; &#10; &lt;span&#10; class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;&#10; &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#golang" aria-label="Anchor"&gt;#&lt;/a&gt;&#10; &lt;/span&gt;&#10; &#10;&lt;/h2&gt;&#10;&lt;p&gt;Go is a powerful yet simple language. The nuances of assembling a &lt;strong&gt;workspace&lt;/strong&gt;, sometimes are overwhelming, yet when it comes to simplicity it is very powerful.&lt;/p&gt;</description></item><item><title>Go: Helpful links</title><link>https://samarthya.me/posts/go-helpful-links/</link><pubDate>Tue, 19 May 2020 11:13:28 +0000</pubDate><guid>https://samarthya.me/posts/go-helpful-links/</guid><description>&lt;h1 class="relative group"&gt;Helpful links&#10; &lt;div id="helpful-links" class="anchor"&gt;&lt;/div&gt;&#10; &#10; &lt;span&#10; class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;&#10; &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#helpful-links" aria-label="Anchor"&gt;#&lt;/a&gt;&#10; &lt;/span&gt;&#10; &#10;&lt;/h1&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;a href="https://golang.org/pkg/net/http/#pkg-overview" target="_blank" rel="noreferrer"&gt;http package&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://golang.org/doc/code.html#Introduction" target="_blank" rel="noreferrer"&gt;How to write go code.&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://golang.org/doc/code.html#Command" target="_blank" rel="noreferrer"&gt;First program&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://golang.org/doc/effective_go.html#introduction" target="_blank" rel="noreferrer"&gt;Effective go&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://golang.org/doc/effective_go.html#web_server" target="_blank" rel="noreferrer"&gt;GO webserver&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://golang.org/pkg/" target="_blank" rel="noreferrer"&gt;GO Packages&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://golang.org/ref/spec#Introduction" target="_blank" rel="noreferrer"&gt;Specification - Go&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://blog.golang.org/json" target="_blank" rel="noreferrer"&gt;JSON in Go blog&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies" target="_blank" rel="noreferrer"&gt;Go command reference&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://blog.golang.org/using-go-modules" target="_blank" rel="noreferrer"&gt;Using Go modules&lt;/a&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;These are some of the helpful links I have used in the past for understanding Go and developing code.&lt;/p&gt;</description></item><item><title>WebService: In golang</title><link>https://samarthya.me/posts/webservice-in-golang/</link><pubDate>Fri, 15 May 2020 11:42:46 +0000</pubDate><guid>https://samarthya.me/posts/webservice-in-golang/</guid><description>&lt;p&gt;Having practiced creating loads of &lt;code&gt;Console based&lt;/code&gt; programs of &lt;code&gt;golang&lt;/code&gt;, it is now time to try something new - A Web Service.&lt;/p&gt;&#10;&lt;p&gt;In this blog, I will try and create a Web Service (RESTful) that will be built entirely on Go.&lt;/p&gt;</description></item><item><title>GoLang: SmipleCipher v2.0</title><link>https://samarthya.me/posts/golang-smiplecipher-v2-0/</link><pubDate>Tue, 12 May 2020 11:23:34 +0000</pubDate><guid>https://samarthya.me/posts/golang-smiplecipher-v2-0/</guid><description>&lt;p&gt;So continuing from the last &lt;a href="https://samarthya.me/posts/golang-simplecipher/" &gt;blog&lt;/a&gt; where I wrote a crude version of SimpleCipher and was inclined on removing the duplicate code, here I am with the improved version.&lt;/p&gt;&#10;&lt;figure&gt;&lt;img&#10; class="my-0 rounded-md"&#10; loading="lazy"&#10; decoding="async"&#10; fetchpriority="auto"&#10; alt="Caesar cipher diagram: each letter is shifted three positions along the alphabet"&#10; width="300"&#10; height="127"&#10; src="https://samarthya.me/posts/golang-smiplecipher-v2-0/simplecipher.png"&#10; srcset="https://samarthya.me/posts/golang-smiplecipher-v2-0/simplecipher.png 800w, https://samarthya.me/posts/golang-smiplecipher-v2-0/simplecipher.png 1280w"&#10; sizes="(min-width: 768px) 50vw, 65vw"&#10; data-zoom-src="https://samarthya.me/posts/golang-smiplecipher-v2-0/simplecipher.png"&gt;&lt;/figure&gt;&#10;&#10;&lt;h3 class="relative group"&gt;Handy links&#10; &lt;div id="handy-links" class="anchor"&gt;&lt;/div&gt;&#10; &#10; &lt;span&#10; class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;&#10; &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#handy-links" aria-label="Anchor"&gt;#&lt;/a&gt;&#10; &lt;/span&gt;&#10; &#10;&lt;/h3&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;code&gt;[fmt&lt;/code&gt;](&lt;a href="https://golang.org/pkg/fmt/" target="_blank" rel="noreferrer"&gt;https://golang.org/pkg/fmt/&lt;/a&gt;) package&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;[strings](https://golang.org/pkg/strings/)&lt;/code&gt; package.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&#10;&lt;h2 class="relative group"&gt;Defining &lt;code&gt;types&lt;/code&gt;&#10; &lt;div id="defining-types" class="anchor"&gt;&lt;/div&gt;&#10; &#10; &lt;span&#10; class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;&#10; &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#defining-types" aria-label="Anchor"&gt;#&lt;/a&gt;&#10; &lt;/span&gt;&#10; &#10;&lt;/h2&gt;&#10;&lt;p&gt;While I compiled and unit tested code the general feeling was what can be optimized.&lt;/p&gt;</description></item><item><title>GoLang: SimpleCipher</title><link>https://samarthya.me/posts/golang-simplecipher/</link><pubDate>Mon, 11 May 2020 10:14:20 +0000</pubDate><guid>https://samarthya.me/posts/golang-simplecipher/</guid><description>&lt;p&gt;Hello back again, Golang is just a new syntax for me. Even though behind the scenes they developers have simplified many things, for a consumer like me writing a program is more about learning the new syntax and getting familiarized with the control and stack.&lt;/p&gt;</description></item><item><title>Say a Number</title><link>https://samarthya.me/posts/say-a-number/</link><pubDate>Sun, 29 Mar 2020 12:00:00 +0000</pubDate><guid>https://samarthya.me/posts/say-a-number/</guid><description>&lt;p&gt;With the Corona-Lockdown in place “literally”, it was time to squeeze out some me-time to continue the quest for GO-Proficiency.&lt;/p&gt;&#10;&lt;p&gt;Sometimes you re-do optimization in your head so many times that it takes a whole day to see through the mistake you are making.&lt;/p&gt;</description></item><item><title>Package String</title><link>https://samarthya.me/posts/package-string/</link><pubDate>Sat, 15 Feb 2020 11:40:19 +0000</pubDate><guid>https://samarthya.me/posts/package-string/</guid><description>&lt;p&gt;Just like Java or C++ there are standard libraries (packages) available with golang. The one that you might end up using the most often is &lt;code&gt;strings&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;For this blog, I was writing another practice &lt;a href="https://exercism.io/my/tracks/go" target="_blank" rel="noreferrer"&gt;exercise&lt;/a&gt; that is meant to count number of words in an input string.&lt;/p&gt;</description></item><item><title>GOLANG: Proteins &amp; RNA</title><link>https://samarthya.me/posts/golang-proteins-rna/</link><pubDate>Mon, 10 Feb 2020 15:06:21 +0000</pubDate><guid>https://samarthya.me/posts/golang-proteins-rna/</guid><description>&lt;p&gt;It was an interesting exercise, and I solved in three ways. More details available here @ &lt;a href="https://exercism.io/my/solutions/94b768430cb84699bcbc07605d3bbe71" target="_blank" rel="noreferrer"&gt;exercism.io&lt;/a&gt;&lt;/p&gt;&#10;&#10;&lt;h2 class="relative group"&gt;Introduction&#10; &lt;div id="introduction" class="anchor"&gt;&lt;/div&gt;&#10; &#10; &lt;span&#10; class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;&#10; &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#introduction" aria-label="Anchor"&gt;#&lt;/a&gt;&#10; &lt;/span&gt;&#10; &#10;&lt;/h2&gt;&#10;&lt;p&gt;RNA can be broken into three nucleotide sequences called codons, and then translated to a polypeptide like so:&lt;/p&gt;</description></item><item><title>Pangram</title><link>https://samarthya.me/posts/pangram/</link><pubDate>Thu, 30 Jan 2020 15:59:51 +0000</pubDate><guid>https://samarthya.me/posts/pangram/</guid><description>&lt;p&gt;I wrote my first program for Pangram in JS &lt;a href="https://samarthya.me/posts/optimizing-in-js/" &gt;here&lt;/a&gt; and attempted few variations to optimize the readability and execution time. This time the code challenge was in Golang and it was satisfying attempt to do in first try.&lt;/p&gt;</description></item><item><title>House that Jack built.</title><link>https://samarthya.me/posts/house-that-jack-built/</link><pubDate>Fri, 17 Jan 2020 12:00:00 +0000</pubDate><guid>https://samarthya.me/posts/house-that-jack-built/</guid><description>&lt;p&gt;Funny thing about simple programs is that there are too many optimization options available that never lets you feel content.&lt;/p&gt;&#10;&lt;p&gt;So here I am trying to solve another problem from &lt;a href="https://exercism.io/my/solutions/19fb3977b3be4ff4bedfee14c711af1a" target="_blank" rel="noreferrer"&gt;exercism.io&lt;/a&gt; which is totally a must visit for anyone who wants to learn and practice.&lt;/p&gt;</description></item><item><title>Concurrency</title><link>https://samarthya.me/posts/concurrency-golang/</link><pubDate>Fri, 03 Jan 2020 12:00:00 +0000</pubDate><guid>https://samarthya.me/posts/concurrency-golang/</guid><description>&lt;h1 class="relative group"&gt;Concurrency and Parallelism – (Helpful &lt;a href="https://blog.golang.org/concurrency-is-not-parallelism" target="_blank" rel="noreferrer"&gt;link&lt;/a&gt;)&#10; &lt;div id="concurrency-and-parallelism--helpful-link" class="anchor"&gt;&lt;/div&gt;&#10; &#10; &lt;span&#10; class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;&#10; &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#concurrency-and-parallelism--helpful-link" aria-label="Anchor"&gt;#&lt;/a&gt;&#10; &lt;/span&gt;&#10; &#10;&lt;/h1&gt;&#10;&lt;p&gt;Last few weeks have been interesting, a new year just embarked, my learning pace slowed down; comparatively due to the festivities and obligations around, but I am still trying to maintain.&lt;/p&gt;</description></item></channel></rss>