<?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 Nilesh Kesar on Medium]]></title>
        <description><![CDATA[Stories by Nilesh Kesar on Medium]]></description>
        <link>https://medium.com/@nilesh.kesar?source=rss-8698dd6b4123------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*GZ7I6e_lY9P3LP7c0GfqXA.jpeg</url>
            <title>Stories by Nilesh Kesar on Medium</title>
            <link>https://medium.com/@nilesh.kesar?source=rss-8698dd6b4123------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 00:29:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nilesh.kesar/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[Debugging Interactively with Python]]></title>
            <link>https://medium.com/revel-systems/debugging-interactively-with-python-d41a519dc58b?source=rss-8698dd6b4123------2</link>
            <guid isPermaLink="false">https://medium.com/p/d41a519dc58b</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Nilesh Kesar]]></dc:creator>
            <pubDate>Mon, 04 Dec 2023 16:23:51 GMT</pubDate>
            <atom:updated>2023-12-05T06:46:26.817Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*XSuTU3xqFjxyrDOz-ULP-Q.png" /></figure><blockquote>Debugging is the process of finding and fixing errors or bugs in the source code of any software. When software does not work as expected, computer programmers study the code to determine why any errors occurred. They use debugging tools to run the software in a controlled environment, check the code step by step, and analyze and fix the issue. — <a href="https://aws.amazon.com/what-is/debugging/#:~:text=Debugging%20is%20the%20process%20of,determine%20why%20any%20errors%20occurred.">AWS</a></blockquote><p>Generally, when we think about bugs when it comes to programming, the definition that comes to mind is they are flaws in our code. Finding these flaws can be difficult, tedious, and very time-consuming. In short, we spend a lot of time doing these tasks, while each bug can be different the techniques we use to find the bugs are generally the same. In our debugging tool kit we might already have a few tricks up our sleeve such as print statements, but did you know about interactive debuggers?</p><h3>Interactive Debuggers</h3><p>Interactive debuggers can be one of a developer’s most useful tools, as it provides them with a step-by-step way to walk through the code as it executes. Some debuggers are baked into IDEs while others are available through the terminal/command line. Either way, the debugger we use has its pros and cons, but all of them will help us figure out what&#39;s going faster and easier. The debugger can provide a lot of useful information such as a stack trace and the variables’ current values.</p><h3>Types of Interactive Debuggers</h3><p>In this article we will be talking about some Python interactive debuggers, please note that even though we are using Python a lot of languages have interactive debuggers, for example in a different article I talked about using Delve for Golang which can be found <a href="https://medium.com/revel-systems/understand-concepts-in-golang-9f0195adf165#:~:text=Debugging%20with%20Delve">here</a>.</p><p>Some examples of interactive debuggers are:</p><h4>PDB</h4><p>PDB stands for Python Debugger and is a part of the standard Python library, meaning no extra installs (woo hoo). This interactive debugger is a command-line debugger. To use it all we need to do is import it and run the Python application as soon as it hits the PDB trace statement it will stop execution and wait for user input.</p><p><a href="https://docs.python.org/3/library/pdb.html">pdb - The Python Debugger</a></p><pre>import pdb</pre><pre><br>def add(a: int, b: int) -&gt; int:<br>    result = a + b<br>    pdb.set_trace() # sets a breakpoint<br>    <br>    return result</pre><pre><br>def main():<br>    add(1,4)</pre><pre><br>if __name__ == &quot;__main__&quot;:<br>    main()</pre><p>In the example, the code will run until it hits pdb.set_trace(). This creates a breakpoint. When the code hits the breakpoint it will stop and wait for user input. The input can be a PDB command (some common ones are below) or we can call a variable to see what it currently is or we can run Python code directly to test something out. See the examples below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NhXzU10Yr0BSH6jk7LpL7Q.png" /></figure><p>In the picture above we are calling the result variable to see exactly what it contains.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UnA9x1gi0lLS7UrZq7lJSQ.png" /></figure><p>In the code above we are calling Python commands to see if manipulating the current variable stored value will it fix our code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*FA966ohEvBPjCcvQMIftEA.png" /></figure><p>In the code above we are calling PDB commands to list out the lines so we can see where we are and what has been executed and what has not.</p><p>You can copy the code above and execute it yourself to try it out. Some quick commands for you to know:</p><pre>Commands<br>----------------------------<br>n # this stands for next and is for telling the debugger to excute the line of code you are on and go to the next line. If a function is being excuted on that line it will *not* go inside the function</pre><pre>s # this stands for step and is for telling the debugger if this line is calling a function to go inside the function.</pre><pre>c # this stands for continue and will continue excuting your code until it hits a breakpoint.</pre><pre>b &lt;line number&gt; # this command stands breakpoint and takes a line number as an argument this command is used to set new breakpoints as the code is running</pre><pre>l # this command stands for list and let you see the source code this is normally the 11 lines at a time from your current line</pre><pre>ll # this command stands for long list and lets you see all the source code for the function your in. (note this avaible after python 3.2)</pre><pre>q # this stands for quit and will quit the debugger</pre><h4>PUDB</h4><p>PUDB is a visual interactive debugger that is actually a command line debugger but looks like how an IDE interactive debugger would look. Note that PUDB is a separate Python library so you would need to install this using your Python package manager.</p><p><a href="https://github.com/inducer/pudb">GitHub - inducer/pudb: Full-screen console debugger for Python</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bjrrK4bd6H7HQXz_5z2YBw.png" /></figure><p>I have highlighted each section to make it a little easier to see what area I’m talking about. In pink on the top left are the code and the line numbers. This lets us see what code has been executed and what will still needs to be executed. You can also hit certain keyboard keys to add things like breakpoints, step in a function, or go to the next line. The orange in the top right is where all variables that are currently in scope are defined (Globals and function level). The gold in the middle right is the current state of the stack, which we can use to go to the files and lines and see how you get to the function you currently are on. The red in the bottom right is all the breakpoints. The green in the bottom left is where you can run Python code to test or manipulate the current variables.</p><h4><strong>VS-Code Debugger</strong></h4><p>VS Code Debugger is an IDE debugger meaning it runs in your IDE and not the command line. There are many IDEs that support interactive debuggers, since VS Code is a popular IDE I am using this one, but note that others also have it such as PyCharm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LHgbDBQFdGgkv_KotxnDhg.png" /></figure><p>On the left, the blue box shows a bug and play icon which we can click. This will open a window up where we can click run and debug you specify what you will be debugging in our case a Python file. This will start the debugger, and you can see the call stack, the current variables, the variables you want to watch for, and the breakpoints you want to use. In the green, at the top middle, you will see continue, next, step in, step out, restart, and stop.</p><p>Next time you are debugging consider using an interactive debugger to help you. These are just a few examples but there are others, I hope this helps you solve your next bug!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d41a519dc58b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/revel-systems/debugging-interactively-with-python-d41a519dc58b">Debugging Interactively with Python</a> was originally published in <a href="https://medium.com/revel-systems">Revel Systems Engineering Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understand Concepts in Golang]]></title>
            <link>https://medium.com/revel-systems/understand-concepts-in-golang-9f0195adf165?source=rss-8698dd6b4123------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f0195adf165</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[golang-tutorial]]></category>
            <dc:creator><![CDATA[Nilesh Kesar]]></dc:creator>
            <pubDate>Mon, 06 Jun 2022 19:02:18 GMT</pubDate>
            <atom:updated>2022-06-07T15:03:53.319Z</atom:updated>
            <content:encoded><![CDATA[<p>This guide will teach you some of the most common things you will use in Go, from Variable Declaration to Goroutines. At the end of this guide, there is a challenge to try and make a small Go app that will use everything taught in this guide. There will also be a link to the source code at the end showing a solution to the challenge question.</p><p><strong>Prerequisites</strong></p><ol><li>You have Go installed</li><li>You know how to generate a go.mod file</li><li>You know how to run a go project</li></ol><p>If you don’t know how to do one or any of these follow this guide <a href="https://medium.com/@nilesh.kesar/writing-your-first-golang-application-12dd6ac1e15">https://medium.com/@nilesh.kesar/writing-your-first-golang-application-12dd6ac1e15</a></p><h3>Getting Started</h3><p>Create an empty folder and open up the newly created folder in your IDE, once the IDE is opened create a file called main.go. Starting on line one type the following.</p><pre><strong>package</strong> main</pre><pre><strong>func</strong> main() {</pre><pre>}</pre><p>Now open up your terminal and navigate into the folder you created earlier, now type go mod init UnderstandingGoConcepts this will create your go mod file and you&#39;re ready to begin.</p><h3>Variable Declaration</h3><p>Now that you have experience printing to the screen try using one or all of the following ways to declare, assign and use a variable.</p><p><strong><em>Declare, Assign, and use</em></strong></p><pre><strong>package</strong> main</pre><pre><strong>import</strong> (<br>&quot;fmt&quot;<br>)</pre><pre><strong>func</strong> main() {<br>  <strong>var</strong> str string<br>  <strong>str</strong> = &quot;Hello World!!&quot;<br>  fmt.<strong>Println</strong>(<strong>str</strong>)<br>}</pre><p><strong><em>Initialize and use</em></strong></p><pre><strong>package</strong> main</pre><pre><strong>import</strong> (<br>&quot;fmt&quot;<br>)</pre><pre><strong>func</strong> main() {<br>  <strong>var</strong> str <strong>string</strong> = &quot;Hello World!!&quot;<br>  fmt.<strong>Println</strong>(<strong>str</strong>)<br>}</pre><p><strong><em>Short Hand Initialize and use</em></strong></p><pre><strong>package</strong> main</pre><pre><strong>import</strong> (<br>&quot;fmt&quot;<br>)</pre><pre><strong>func</strong> main() {<br>  str := &quot;Hello World!!&quot;<br>  fmt.<strong>Println</strong>(<strong>str</strong>)<br>}</pre><h3>Debugging with Delve</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*67y2QagWjrYlGbuA65o9kA.png" /></figure><p>Delve is one of the recommended Go Debuggers to install you can follow the steps <a href="https://github.com/go-delve/delve/tree/master/Documentation/installation">Delve Installation Steps</a></p><p>We are going to be working off the hello world project from above but will modify it a little bit.</p><pre><strong>package</strong> main</pre><pre><strong>import</strong> (<br>  &quot;fmt&quot;<br>  &quot;runtime&quot;<br>)</pre><pre><strong>func</strong> main() {<br>  str := &quot;Hello World!!&quot;<br>  name := &quot;John Doe&quot;</pre><pre>  runtime.<strong>Breakpoint</strong>()</pre><pre>  fmt.<strong>Println</strong>(<strong>str</strong>)<br>  fmt.<strong>Println</strong>(<strong>name</strong>)<br>}</pre><p>runtime.Breakpoint() is how you can set the delve debugger breakpoint, this will throw an error if left in when running the Go Project normally, but we are going to run the project with Delve in debug mode, this will hit the breakpoint and stop. There are two ways you can run your code to debug it, you can run the built executable Go project which you would have to rebuild anytime you make a change to the source code or you can run the debugger which will compile the Go code but will not produce an executable. For now, we will go with the second where we compile the Go code but don’t produce an executable. In your terminal window type dlv debug this will start the delve debug session in which you will see (dlv) with this, you can type c and press enter this will continue till it reaches the end of your program or a breakpoint in our case it will be a breakpoint. Now you can type print str or print name and you will see the value stored in them. These breakpoints also can work on goroutines and channels (which will be covered in the next lesson)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZX3JjnlpHR42BRXh-Js9eg.png" /></figure><p>Once you finished your debugging session you can either continue pressing c or you can press q to quit the debugging session.</p><h3>Packages</h3><p>Now let&#39;s talk about packages, in Go a package is how you can separate different pieces of code into their own file and folder. Each folder in Go must contain only one package and must be unique to the project. An Example of this is let&#39;s say you have the directory tree below, the main package would be the root directory, then you would have another package named enums in the enum folder and another package named structs in the structs folder. We will show a full example in the next section <strong>Custom Types and Data Structures</strong></p><pre>| main.go<br>| go.mod<br>| --&gt; types<br>|     --&gt; enums<br>|         --&gt; enumTest.go<br>|     --&gt; structs<br>|         --&gt; structTest.go</pre><h3>Custom Types and Data Structures</h3><p>Let&#39;s make the file structure from above in our Current project</p><pre>// enumTest.go</pre><pre><strong>package</strong> enums</pre><pre><strong>type</strong> enumTest <strong>int64</strong></pre><pre>const (<br>  Testing <strong>enumTest</strong> = <strong>iota </strong>// 0<br>  Player  <strong>enumTest</strong> = <strong>iota</strong> // 1<br>)</pre><p>To explain what&#39;s going on iota in Go is a way you can set up enums so that the list of const will use the next unsigned integer so Testing will be 0 and Player will be 1.</p><pre>// structTest.go</pre><pre><strong>package</strong> Structs</pre><pre><strong>type</strong> StructTest <strong>struct</strong> {<br>  Test <strong>string</strong><br>  JSONString <strong>string</strong> `json:&quot;abc&quot;`<br>  privateInteger <strong>int</strong><br>}</pre><p>To explain what&#39;s going on you here, Structs are like Classes, Test is a public member variable of type string. JSONString is a public member variable of type string that when marshaling and unmarshalling will map JSONString to the JSON value abc. privateInteger is a private member variable of type int. In Go, you define private and public by the first letter capitalization.</p><h3>Goroutines</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q0eyE8egZOPiqEYZAArkjQ.png" /></figure><p>In Go, there is a concept Goroutines, essentially they are lightweight threads. They are highly performant and used to do things in parallel throughout your Go app. To better understand these concepts let’s update our hello world application to better show what Goroutines can really do. You can run a Goroutine on any function, with that said you can also make an anonymous goroutine function below there are examples showing them off.</p><pre><strong>package</strong> main</pre><pre><strong>import</strong> (<br>  &quot;fmt&quot;<br>  &quot;time&quot;<br>)</pre><pre><strong>func</strong> printFunc(name <strong>string</strong>) {<br>  <strong>for</strong> i := 1; i &lt; 4; i++ {<br>    fmt.<strong>Println</strong>(<strong>name </strong>+ &quot;: &quot;, <strong>i</strong>)<br>  }<br>}</pre><pre><strong>func</strong> main() {<br>  str := &quot;Hello World!!&quot;<br>  fmt.<strong>Println</strong>(<strong>str</strong>)</pre><pre>  fmt.<strong>Println</strong>(&quot;Showing off GoRoutines&quot;)<br>  fmt.<strong>Println</strong>()<br>  fmt.<strong>Println</strong>()</pre><pre>  // running go routine using existing function<br>  <strong>go</strong> <strong>printFunc</strong>(&quot;GoRoutine 1&quot;)</pre><pre>  // running function in main thread<br>  <strong>printFunc</strong>(&quot;Main thread&quot;)</pre><pre>  // running anonymous go routine<br>  <strong>go</strong> <strong>func</strong>() {<br>    fmt.<strong>Println</strong>(&quot;Anonymous function GoRoutine&quot;)<br>  }()</pre><pre>  <strong>//</strong> Sleep is needed so main process doesn&#39;t exit until all is done<br>  time.<strong>Sleep</strong>(time.<strong>Second</strong> * 5)<br>  fmt.<strong>Println</strong>(&quot;Done&quot;)<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HOy8Vr-HAphDFX8lLJNrag.png" /></figure><p>As you can see the goroutine doesn’t run in sequence and other goroutines can run in between them.</p><h3>Channels</h3><p>In Go, there is a concept called Channels, it’s used to pass data between Goroutines. The way channels work is they have a buffer, and the buffer holds onto the value until it’s read from, and until it’s read from more data can not enter the buffer, for every write to the buffer there must be a read from the buffer else you can enter a deadlock. In the example below we are going to send all of our messages to a standard channel to print out to the console, this will ensure that only one process is writing out, were pretending the console is a file where we only want one thing written to the file at a time.</p><p>To Write to a Channel you do &lt;channel_name&gt; &lt;- &lt;what you want written&gt;</p><p>To Read from a Channel you do &lt;new_var &lt;- &lt;channel_name&gt;</p><pre><strong>package</strong> main</pre><pre><strong>import</strong> (<br>  &quot;fmt&quot;<br>  &quot;time&quot;<br>)</pre><pre>// create global channel<strong><br>var</strong> messages <strong>chan</strong> <strong>string</strong> = <strong>make</strong>(chan <strong>string</strong>)</pre><pre><strong>func</strong> handleMessage() {<br>  <strong>var</strong> msg <strong>string</strong><br>  <strong>for</strong> {</pre><pre>    // read string from buffer and clear buffer<br>    msg = &lt;-<strong>messages</strong> <br>    <br>    if msg == &quot;exit&quot; {<br>      fmt.<strong>Println</strong>(&quot;Ending Channel reads&quot;)<br>      break<br>    }</pre><pre>    fmt.<strong>Println</strong>(msg)<br>  }<br>}</pre><pre><strong>func</strong> printFunc(name string) {<br>  <strong>for</strong> i := 1; i &lt; 4; i++ {<br>    // write interpolated string to the buffer<strong><br>    messages</strong> &lt;- fmt.<strong>Sprintf</strong>(&quot;%s%s%d&quot;, <strong>name</strong>, &quot;: &quot;, <strong>i</strong>)<br>  }<br>}</pre><pre><strong>func</strong> main() {<br>  // reading from channel should be run in seperate thread so its<br>  // not blocking main thread<br>  <strong>go</strong> <strong>handleMessage</strong>()<br>  <br>  str := &quot;Hello World!!&quot;<br>  <br>  // write a varaible string to the buffer<br>  <strong>messages</strong> &lt;- str<br>  // write hardcoded string to the buffer<br>  <strong>messages</strong> &lt;- &quot;Showing off GoRoutines\n\n&quot;</pre><pre>  <strong>printFunc</strong>(&quot;printFunc - GoRoutine&quot;)<br>  <br>  <strong>printFunc</strong>(&quot;Main thread&quot;)<br>  <br>  <strong>go</strong> <strong>func</strong>() {<br>    <strong>messages</strong> &lt;- &quot;Anonymous function GoRoutine&quot;<br>  }()</pre><pre>  time.<strong>Sleep</strong>(time.<strong>Second</strong> * 1)<br>  <strong>messages</strong> &lt;- &quot;Done&quot;<br>  time.<strong>Sleep</strong>(time.<strong>Second</strong> * 1)<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DL7j5ih2kte6YMqejJh1gA.png" /></figure><h3><strong>Put it all together (Challenge)</strong></h3><p>Now let&#39;s put all that together, we are going to be creating a little game called echo, in this game whenever someone types echo followed by a word or phrase we will repeat that phrase. An example of some output would be</p><pre>&gt; echo hello<br>hello<br>&gt; echo hi <br>hi<br>&gt; hello<br>&gt; echo hello<br>hello</pre><p>Here is the stuff you need to know to make sure you have a valid solution:</p><ol><li>You must use go routines, channels, structs, and enums in your solution.</li><li>A single Goroutine is the only thing allowed to print to the screen anything wanting to print to the screen must send the data to that single Goroutine</li><li>You should handle the following three scenarios: when a user begins their input with echo the app should repeat the user input when a user&#39;s input does not begin with echo, the app should not print anything and wait for the user to try inputting again, and lastly if the user types exit by itself, the application must end</li></ol><p><strong>Put it all together (Completed Code)</strong></p><p>The completed code lives in the link below, note you could complete this any way you wish, but you must use go routines, channels, structs, and enums in your solution. <br><a href="https://gitlab.com/NKesar_RS/understanding-go-concepts">https://gitlab.com/NKesar_RS/understanding-go-concepts</a></p><h4>Credits:</h4><p>Gopher Pictures: <a href="https://github.com/MariaLetta/free-gophers-pack">https://github.com/MariaLetta/free-gophers-pack</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f0195adf165" width="1" height="1" alt=""><hr><p><a href="https://medium.com/revel-systems/understand-concepts-in-golang-9f0195adf165">Understand Concepts in Golang</a> was originally published in <a href="https://medium.com/revel-systems">Revel Systems Engineering Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Writing Your First Golang Application]]></title>
            <link>https://medium.com/revel-systems/writing-your-first-golang-application-12dd6ac1e15?source=rss-8698dd6b4123------2</link>
            <guid isPermaLink="false">https://medium.com/p/12dd6ac1e15</guid>
            <category><![CDATA[go-developer]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[go]]></category>
            <dc:creator><![CDATA[Nilesh Kesar]]></dc:creator>
            <pubDate>Mon, 06 Jun 2022 19:01:03 GMT</pubDate>
            <atom:updated>2022-06-08T06:13:38.891Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_TTBoq4yXoHnZdEgROOMhw.png" /></figure><p>Writing your first Golang Application and becoming a certified gopher isn’t as hard as you might imagine. In this tutorial, we will build a Hello World project, run it, and build an executable. If you already know how to do all that you can go to this tutorial where it goes into Go lang concepts <a href="https://medium.com/@nilesh.kesar/understand-concepts-in-golang-9f0195adf165">https://medium.com/@nilesh.kesar/understand-concepts-in-golang-9f0195adf165</a></p><h3>What Is Go</h3><p>Go or GoLang is an open-sourced general purpose programming language created at Google in 2007, it is a compiled programming language, and takes things from C++, Java, and Python. It is meant to be easier to use than C++ while also being optimized for speed and efficiency. Also, their mascot/logo is a blue gopher, which personally always brings a smile to my face.</p><figure><img alt="A Smiling Blue Go Gopher" src="https://cdn-images-1.medium.com/max/1024/1*tpNKC2035NKyDqaFSqGLcw.png" /></figure><h3>Install Go</h3><p>Go to the official Go website <a href="https://go.dev/dl/">https://go.dev/dl/</a> and download the version that matches your architecture. To verify that you installed it correctly in your terminal run the following command go version and you should see some output like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*J8Tu2gNy6xUZiPp7QtvqUw.png" /></figure><h3>Download IDE</h3><p>You can install a number of different Go IDEs such as VSCode or GoLand, more links are here <a href="https://www.tabnine.com/blog/top-7-golang-ides-for-go-developers/">https://www.tabnine.com/blog/top-7-golang-ides-for-go-developers/</a>. For this tutorial, we will be using VSCode.</p><h3>Writing Hello World</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IN_HwXh3tKTgEdtoOYGT7A.png" /></figure><p>Create an empty folder and open up it up in your IDE, once opened create a file called main.go. Starting on line one type the following. This declares that your file belongs to the main package which is like modules if you&#39;re familiar with python. If you are not familiar with python, think of packages as a folder each folder is a package of Go code. Each package has a unique name and you will always start with the main package. As well you will declare your main function which is where all code will start from.</p><pre><strong>package</strong> main</pre><pre><strong>func</strong> main() {</pre><pre>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ej5YAk-Ynts9E1vgAG8cEQ.png" /></figure><p>After that let’s write hello world to the screen. Inside your Main file type</p><pre><strong>package</strong> main</pre><pre><strong>import</strong> (<br>  &quot;fmt&quot;<br>)</pre><pre><strong>func</strong> main() {<br>  fmt.<strong>Println</strong>(&quot;Hello World!!&quot;)<br>}</pre><p>Now open up your terminal and type go run main.go this will run your go application and print “Hello World!!” to the terminal</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vL_f46H-NR4W1Rl2Gcmdcw.png" /></figure><h3>Build an executable file</h3><p>With your terminal open type go mod init firstGoProject this will create a go.mod file, if you are familiar with npm it&#39;s just like your package.json, this file names your project, this will also be where you specify any libraries you are using for this project. If you have any unused libs you can run go mod tidy this will clean your go.mod file it will get rid of any unused dependencies from the file and if you have any dependencies it will create a go.sum file, the go.sum file is an auto-generated file and is like a package-lock.json which go uses to make sure it installs the right package and version.</p><p>Now run go build this will create a binary executable file which will automatically be compiled to run on your host OS, but you can change it to different architectures with build flags. Now run ./firstGoProject and it will run the executable. The nice thing about Go is that like docker everything is packaged up when you build so you can run it anywhere exactly the same way. You don’t even need Go installed on the OS that is running the executable! Congratulations on becoming a certified gopher!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bo3hJ6VEl62wLasDQnLB0A.png" /></figure><h3>Next Steps</h3><p>This is a more advanced tutorial explaining Go concepts <a href="https://medium.com/@nilesh.kesar/understand-concepts-in-golang-9f0195adf165">https://medium.com/@nilesh.kesar/understand-concepts-in-golang-9f0195adf165</a></p><h4>Credits:</h4><p>Gopher Pictures: <a href="https://github.com/MariaLetta/free-gophers-pack">https://github.com/MariaLetta/free-gophers-pack</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12dd6ac1e15" width="1" height="1" alt=""><hr><p><a href="https://medium.com/revel-systems/writing-your-first-golang-application-12dd6ac1e15">Writing Your First Golang Application</a> was originally published in <a href="https://medium.com/revel-systems">Revel Systems Engineering Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>