<?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 Fishnux on Medium]]></title>
        <description><![CDATA[Stories by Fishnux on Medium]]></description>
        <link>https://medium.com/@fishnux?source=rss-1252e3b8a400------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_9Xuo1q-usMToahmDio3Xw.png</url>
            <title>Stories by Fishnux on Medium</title>
            <link>https://medium.com/@fishnux?source=rss-1252e3b8a400------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 14:58:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@fishnux/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[Golang: What the heck is a composite literal?]]></title>
            <link>https://medium.com/@fishnux/golang-what-the-heck-is-a-composite-literal-6dd194480a75?source=rss-1252e3b8a400------2</link>
            <guid isPermaLink="false">https://medium.com/p/6dd194480a75</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[golang-tutorial]]></category>
            <dc:creator><![CDATA[Fishnux]]></dc:creator>
            <pubDate>Fri, 28 Jul 2017 23:56:56 GMT</pubDate>
            <atom:updated>2017-08-02T16:31:48.851Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DBQ_h25Dvps3BftZEgH7sg.png" /></figure><p><em>Disclaimer: I’m still a beginner. If notice any technical error, please kindly let me know. Thanks!</em></p><p>It has been a few days since I started learning Go. I’m now learning about data structures like Array and Slice, and came across this exercise:</p><pre>Using a COMPOSITE LITERAL:<br>* Create an ARRAY which holds 5 VALUES of TYPE int<br>* Assign VALUES to each index position.</pre><p>Let’s forget the composite literal thing. On my very first attempt, I did something like this:</p><pre>var myArray [5]int<br>for i := 0; i &lt; len(myArray); i++ {<br>    myArray[i] = 3<br>}</pre><p>The first statement initializes an array, that holds 5 integers. First part of the exercise done!</p><p>The second statement loops through the array, and assigns the value “3” for each index. You can run the code <a href="https://play.golang.org/p/CeflN0JANk">here,</a> producing the result:</p><pre>[3 3 3 3 3]</pre><p>Alright, looks like we managed to finish the exercise. But, what the heck is a composite literal? And why does it matter for this exercise?</p><p>It turns out, a composite literal is <em>something </em>that can make our lives easier when we want to assign values upon a variable initialization. If we wanted to fill an array with “3” (or any other combination of integers) upon its initialization, we could use the following code instead of doing a <strong>for</strong> statement:</p><pre>myArray := [5]int{3, 3, 3, 3, 3} // Short syntax</pre><pre>// OR</pre><pre>var myArray [5]int = [5]int{3, 3, 3, 3, 3} // Long syntax</pre><p>As a beginner, you’re probably scratching your head trying to understand it. Let’s break it down, step-by-step:</p><pre>var myArray [5]int</pre><p>That code declares an array of size 5, that holds integers. That is, it holds 5 integers. And we’re assigning a value to that array:</p><pre> = [5]int{3, 3, 3, 3, 3}</pre><p>That’s a composite literal, that <strong>evaluates</strong> to an array of size 5, with the values 3, 3, 3, 3, 3:</p><pre>[3, 3, 3, 3, 3]</pre><p>Basically we’re just filling an array upon initialization, without manually iterating through each index and setting a value. You’ve probably seen them in other programming languages:</p><pre>&lt;?php<br>$myArray = [3, 3, 3, 3, 3];</pre><p>This was particularly interesting for me, because I always used composite literals in other programming languages, but never realized it was called a “composite literal”.</p><p>If you want to learn more about about it, the Go spec is an awesome resource:</p><blockquote>Composite literals construct values for structs, arrays, slices, and maps and create a new value each time they are evaluated. They consist of the type of the literal followed by a brace-bound list of elements.</blockquote><p><a href="https://golang.org/ref/spec#Composite_literals">The Go Programming Language Specification - The Go Programming Language</a></p><p>Keep learning! You’re doing a great job!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6dd194480a75" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting started with Go (Golang) on Windows]]></title>
            <link>https://medium.com/@fishnux/getting-started-with-go-golang-on-windows-8f9e50f6f707?source=rss-1252e3b8a400------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f9e50f6f707</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Fishnux]]></dc:creator>
            <pubDate>Sat, 15 Jul 2017 16:19:57 GMT</pubDate>
            <atom:updated>2017-07-15T21:08:25.812Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<p>Recently I’ve decided to learn this awesome programming language called <a href="https://golang.org/">Go</a>. I’ve decided to write this post to let the world know how I’ve set up my <em>proper</em> development workspace on Windows.</p><p>If you’re reading this, you most likely have worked with a terminal (a.k.a. command line prompt) in the past. I happen to really like this project called <a href="http://scoop.sh/">Scoop</a>. Basically, it’s a command line installer for Unix tools (e.g.: curl, grep, cat, git) and a few other goodies.</p><p>Ready to download the Go installer at the official website? Let’s try my way instead! <em>Go</em> to your favourite command line prompt (I use <a href="http://cmder.net/">Cmder</a>) and type the following:</p><pre>scoop install go</pre><p>This will magically download Go, install it and configure the GOROOT environment variable. Exciting, isn’t it?</p><p>Now, before making our Hello World program, we need to configure our “Go Workspace”. In order to facilitate collaboration with different people, we need to follow certain “rules”. One of those rules is creating a “Go Workspace”. In my case, I’ve created a GoWorkspace directory in my Documents folder:</p><pre>C:\Users\Me\Documents\GoWorkspace</pre><p>Inside it, create the folders “bin”, “src” and “pkg”. Now, you have to add that folder (“GoWorkspace”) to your environment variable GOPATH:</p><pre>setx GOPATH &quot;C:\Users\<strong>&lt;your_username&gt;</strong>\Documents\GoWorkspace&quot;</pre><p>Make sure you close and re-open your terminal, to ensure the new environment variables are properly loaded.</p><p>Next, assuming you have a GitHub account, inside the “src” directory you should create a folder with your username. In my case, it would be like this:</p><pre>C:\Users\Me\Documents\GoWorkspace\src\github.com\fishnux</pre><p>Make sure you don’t forget to create the “github.com” folder.</p><p>Inside our newly created directory, we can create our new project “HelloWorld”:</p><pre>C:\Users\Me\Documents\GoWorkspace\src\github.com\fishnux\HelloWorld</pre><p>That’s the folder where you should create the Git repository (git init).</p><p>Now, we have to create our main.go file. Let’s make a pause and talk about code editors. There are a lot of them, but I’ve decided to stick with Visual Studio Code. Make sure you download it and install the following extension:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*nruVTMGpkZiMAQRl39DneQ.png" /></figure><p>And then, open VSCode on the folder “Hello World”, and write the following (please, <strong>don’t copy-paste</strong>):</p><pre>package main</pre><pre>func main() {<br>    fmt.PrintLine(&quot;Hello World!&quot;)<br>}</pre><p>The reason I asked you to not copy-paste, is because I wanted to show you how awesome is code completion. And also, notice that the fmt package is imported automatically:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/373/1*ChHcjHtaRwCx0Lt1PvBKnQ.png" /></figure><p>You can now press F5 to run/debug that program. You should get “Hello World!” as the output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/347/1*hzxW6KTWcEGFjXR9gdZu9Q.png" /></figure><p>Now it’s your turn, build something awesome :)</p><p>P.S.: We’ve used the name “HelloWorld” for our project. But by <a href="https://golang.org/doc/effective_go.html#package-names">convention</a>, package names are usually lower case. Take that in consideration when building serious/shareable projects.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f9e50f6f707" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>