title: Go error: go : go.mod file not found in current directory or any parent directory; (working on GOPATH/src)
body: <p>I installed Golang and faced with <code>go.mod file not found in current directory or any parent directory</code> error at very first time.</p>
  <p>But I'm working on <code>&lt;GOPATH&gt;/src</code> directory. Isn't go.mod only required if current working directory is located out of GOPATH?</p>
  <p><strong>Here's detailed information</strong></p>
  <p>Go version : <code>go version go1.16.4 windows/amd64</code></p>
  <p>Go env :</p>
  <pre><code>set GO111MODULE=
  set GOARCH=amd64
  set GOBIN=
  set GOCACHE=C:\Users\&lt;userName&gt;\AppData\Local\go-build
  set GOENV=C:\Users\&lt;userName&gt;\AppData\Roaming\go\env
  set GOEXE=.exe
  set GOFLAGS=
  set GOHOSTARCH=amd64
  set GOHOSTOS=windows
  set GOINSECURE=
  set GOMODCACHE=C:\Users\&lt;userName&gt;\go\pkg\mod
  set GONOPROXY=
  set GONOSUMDB=
  set GOOS=windows
  set GOPATH=C:\Users\&lt;userName&gt;\go
  set GOPRIVATE=
  set GOPROXY=https://proxy.golang.org,direct
  set GOROOT=C:\Program Files\Go
  set GOSUMDB=sum.golang.org
  set GOTMPDIR=
  set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
  set GOVCS=
  set GOVERSION=go1.16.4
  set GCCGO=gccgo
  set AR=ar
  set CC=gcc
  set CXX=g++
  set CGO_ENABLED=1
  set GOMOD=NUL
  set CGO_CFLAGS=-g -O2
  set CGO_CPPFLAGS=
  set CGO_CXXFLAGS=-g -O2
  set CGO_FFLAGS=-g -O2
  set CGO_LDFLAGS=-g -O2
  set PKG_CONFIG=pkg-config
  set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\&lt;userName&gt;\AppData\Local\Temp\go-build4258913208=/tmp/go-build -gno-record-gcc-switches
  </code></pre>
  <p>Working directory: <code>C:\Users\&lt;userName&gt;\go\src\main.go</code></p>
  <p>Code :</p>
  <pre><code>package main
  
  import &quot;fmt&quot;
  
  func main() {
      fmt.Println(&quot;HELLO&quot;)
  }
  </code></pre>
  <p>And Error:</p>
  <pre><code>go: go.mod file not found in current directory or any parent directory; see 'go help modules'
  Build process exiting with code: 1 signal: null
  </code></pre>
  <p>p.s. I'm using <code>VS Code</code></p>