<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: reluth</title>
    <description>The latest articles on Forem by reluth (@reluth).</description>
    <link>https://forem.com/reluth</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1211327%2Fb92cc52e-a153-4b3e-a002-b44a2c0294fb.jpeg</url>
      <title>Forem: reluth</title>
      <link>https://forem.com/reluth</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/reluth"/>
    <language>en</language>
    <item>
      <title>Setting Up the Go Programming Environment on Windows 11</title>
      <dc:creator>reluth</dc:creator>
      <pubDate>Thu, 16 Nov 2023 14:45:52 +0000</pubDate>
      <link>https://forem.com/reluth/setting-up-the-go-programming-environment-on-windows-11-8j9</link>
      <guid>https://forem.com/reluth/setting-up-the-go-programming-environment-on-windows-11-8j9</guid>
      <description>&lt;p&gt;Go is a statically typed and compiled high-level programming language crafted at Google to address various programming challenges, including multi-core processing, networking, computing clusters, and web development models.&lt;/p&gt;

&lt;p&gt;The syntax of Go resembles a user interface in the language. It boasts a clean, straightforward, and easily understandable structure. Unlike some languages, Go omits default parameters and conventional private and public keywords. Instead, it relies on the initial letter of an identifier to discern its visibility.&lt;/p&gt;

&lt;h3&gt;
  
  
  Start developing Golang
&lt;/h3&gt;

&lt;p&gt;Before delving into the fascinating problem-solving aspects and syntax of Golang, let's initiate our journey by setting up this language on various operating systems. For the purpose of this guide, we will be using Windows 11.&lt;/p&gt;

&lt;h3&gt;
  
  
  Install Ubuntu on WSL2
&lt;/h3&gt;

&lt;p&gt;With the Windows Subsystem for Linux (WSL), developers can harness the capabilities of both the Windows and Linux operating systems.&lt;/p&gt;

&lt;p&gt;Open the Windows Terminal and utilize it to install Ubuntu.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wsl --install -d Ubuntu
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Install Docker desktop
&lt;/h3&gt;

&lt;p&gt;Simple click to download &lt;a href="https://www.docker.com/products/docker-desktop/"&gt;https://www.docker.com/products/docker-desktop/&lt;/a&gt;&lt;br&gt;
Once downloaded and installed, open Docker Desktop and navigate to &lt;code&gt;Settings -&amp;gt; Resources -&amp;gt; WSL Integration&lt;/code&gt;, then enable &lt;code&gt;Ubuntu&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Return to the WSL terminal, and witness the magic with the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker ps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Install gvm
&lt;/h3&gt;

&lt;p&gt;Install GVM, which offers an interface for managing Go versions, by executing the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get update
sudo apt-get install bison
bash &amp;lt; &amp;lt;(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install Go and set the version to 1.21.4 using the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gvm install go1.21.4 -B
gvm use go1.21.4 --default
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Switching to other Go versions is easy; simply use the two commands mentioned above.&lt;/p&gt;

&lt;h3&gt;
  
  
  Start develop with vscode
&lt;/h3&gt;

&lt;p&gt;Dowload here: &lt;a href="https://code.visualstudio.com/"&gt;https://code.visualstudio.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Open Visual Studio Code, and install the &lt;code&gt;Go&lt;/code&gt; and &lt;code&gt;WSL&lt;/code&gt; extensions. Choose &lt;code&gt;Open a Remote Window.&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Hello World in Golang
&lt;/h3&gt;

&lt;p&gt;Create a directory and navigate into it. Run the following command to initialize your Golang project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;go mod init github.com/reluth/hello-world
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create &lt;code&gt;main.go&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"fmt"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello World!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open your terminal and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;go run main.go
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output: &lt;code&gt;Hello World!&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Congratulations on completing the initial steps to set up your Go development environment on Windows 11! &lt;/p&gt;

&lt;p&gt;By installing WSL2, Docker Desktop, GVM, and configuring Visual Studio Code, you've laid a solid foundation for building Go applications.&lt;/p&gt;

&lt;p&gt;Feel free to explore more advanced features of Go, leverage its concurrency model, and tap into the rich ecosystem of libraries and tools available. Happy coding!&lt;/p&gt;

&lt;h3&gt;
  
  
  Reference
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Go_(programming_language)"&gt;Go (programming language)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://go.dev/talks/2012/splash.article"&gt;Go at Google: Language Design in the Service of Software Engineering&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=e6uyGCoLiWA&amp;amp;ab_channel=ProgrammingwithJohn"&gt;Installing WSL and Docker in Windows 11&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/moovweb/gvm"&gt;Go Version Manager&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>go</category>
      <category>docker</category>
      <category>wsl2</category>
      <category>vscode</category>
    </item>
  </channel>
</rss>
