<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Go on Janusworx</title>
    <link>https://janusworx.com/tags/go/</link>
    <description>Recent content in Go on Janusworx</description>
    <image>
      <title>Janusworx</title>
      <url>https://janusworx.com/images/jw-logo.png</url>
      <link>https://janusworx.com/images/jw-logo.png</link>
    </image>
    <generator>Hugo -- 0.163.0</generator>
    <language>en</language>
    <lastBuildDate>Wed, 15 Mar 2023 19:11:11 +0530</lastBuildDate>
    <atom:link href="https://janusworx.com/tags/go/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Quick Fix: Go Mod File Not Found in Current Directory</title>
      <link>https://janusworx.com/work/quick-fix-go-mod-file-not-found-in-current-directory/</link>
      <pubDate>Wed, 15 Mar 2023 19:11:11 +0530</pubDate>
      <guid>https://janusworx.com/work/quick-fix-go-mod-file-not-found-in-current-directory/</guid>
      <description>&lt;p&gt;As I have begun learning Go (or &lt;code&gt;golang&lt;/code&gt; as I needed to use for searching on the web), I’ve been running into some sort of chasm that the Go language seems to have crossed&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; that my old textbook obviously could not have foreseen when it was published.&lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;The book asks me to do a &lt;code&gt;go run .&lt;/code&gt; to get my file to compile and run.&lt;br&gt;
Go seems to having none of it.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>As I have begun learning Go (or <code>golang</code> as I needed to use for searching on the web), I’ve been running into some sort of chasm that the Go language seems to have crossed<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup> that my old textbook obviously could not have foreseen when it was published.<sup id="fnref:2"><a href="#fn:2" class="footnote-ref" role="doc-noteref">2</a></sup></p>
<p>The book asks me to do a <code>go run .</code> to get my file to compile and run.<br>
Go seems to having none of it.</p>
<pre tabindex="0"><code>go: go.mod file not found in current directory or any parent directory; see &#39;go help modules&#39;
</code></pre><p>Some searching on the web, and I found setting the <code>GO111MODULE</code> environment variable to <code>auto</code> or <code>off</code> will do the trick. So …</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>export GO111MODULE<span style="color:#f92672">=</span><span style="color:#e6db74">&#39;auto&#39;</span>
</span></span></code></pre></div><p>did indeed do the trick.</p>
<p>I’m not putting this in my <code>.bashrc</code> to make it persistent though. The Go folks must have had some reason to make this change, which I’m (currently) not aware of. Was it architectural? Security related? That is a web search for another day.</p>
<p>Right now the code compiles and I must be off to my next exercise.</p>
<p><hr style='margin-left: auto; margin-right: auto; margin-bottom: 40px; margin-top: 50px; width:100px; border: none; background-color:rgb(238, 238, 238); color: rgb(238, 238, 238);  height: 1px;'/>

Feedback on this post? Mail me at <a href="mailto:feedback@janusworx.com">feedback@janusworx.com</a>
<br>

<br>

P.S. Subscribe to my <a href="https://janusworx.com/subscribe/">mailing list!</a><br>
Forward these posts and letters to your friends and get them to subscribe!<br>
P.P.S. Feed my <a href="https://www.amazon.in/hz/wishlist/ls/2QAUKHHAMOOVS?ref_=wl_share">insatiable reading habit.</a></p>
<hr>
<div class="footnotes" role="doc-endnotes">
<hr>
<ol>
<li id="fn:1">
<p>I’m using v1.20.1&#160;<a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
<li id="fn:2">
<p>I’m learning from Packt’s, The Go Workshop (Delio D’Anna et al), 2019&#160;<a href="#fnref:2" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
</ol>
</div>
]]></content:encoded>
    </item>
  </channel>
</rss>
