title: no required module provides package <imported-package>: go.mod file not found in current directory or any parent directory;
body: <p>I have seen possible duplicate questions but they seem to suggest use of go modules. But I was wondering why the well <a href="https://www.gopl.io/" rel="nofollow noreferrer">documented</a> functionality of GOPATH doesn't work out of the box:-</p>
  <blockquote>
  <p>the import path P denotes the package found in the directory DIR/src/P
  for some DIR listed in the GOPATH environment variable (For more
  details see: 'go help gopath').</p>
  </blockquote>
  <p>I am trying to use root.go from the file main.go</p>
  <pre><code>~/src/github.com/himanshugarg/sicp/root$ ls
  main.go  root.go  test.go
  </code></pre>
  <p>The file root.go has the package declaration:-</p>
  <pre><code>~/src/github.com/himanshugarg/sicp/root$ head root.go 
  // Find square root using Newton's method
  // Based on SICP's on page 30
  package root
  
  import (
    &quot;math&quot;
  );
  
  func Sqrt(x float64) float64{
    goodEnough := func (guess float64) bool {
  </code></pre>
  <p>And the file main.go imports root:-</p>
  <pre><code>~/src/github.com/himanshugarg/sicp/root$ head main.go 
  package main
  
  import (
    &quot;fmt&quot;
    &quot;os&quot;
    &quot;strconv&quot;
    &quot;github.com/himanshugarg/sicp/root&quot;
  );
  
  func main() {
  </code></pre>
  <p>GOPATH is set correctly:-</p>
  <pre><code>~/src/github.com/himanshugarg/sicp/root$ echo $GOPATH
  /home/hgarg
  </code></pre>
  <p>But the build fails:-</p>
  <pre><code>~/src/github.com/himanshugarg/sicp/root$ go build main.go 
  main.go:7:3: no required module provides package github.com/himanshugarg/sicp/root: go.mod file not found in current directory or any parent directory; see 'go help modules'
  </code></pre>
  <p>Surely I can use go modules but I just want to be sure that GOPATH no longer works or that I am not missing something.</p>