尽管设置了GOPATH,但是echo $ GOPATH不返回任何内容

I have this weird issue.

When I run go env, I get the following:

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ethanc/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/ethanc/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/ethanc/marketstore/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build154822748=/tmp/go-build -gno-record-gcc-switches"

But when, I run echo $GOPATH, I get an empty new line. This happens for all other GO environment values as well when I try to echo them out: Empty GOPATH result

This doesn't make sense because when I try to print out other path variables like echo $HOME, I get the correct value:

/home/ethanc

Does anyone have any idea why when I echo my GOPATH, only a new line is returned?

This is the default value for GOPATH.

Since it's never set, go will use it's reasonable default.

Main consquence of course is all your go projects sharing this $GOPATH.

Thank you @DonSimon (https://stackoverflow.com/users/10453847/don-simon) for pointing me in the right direction.

So, while my go environment variables were set up correctly and go env returned the correct env. variables, it wasn't set in my bash shell.

I just followed the instructions of setting the GOPATH automatically in my terminal: enter link description here

Specifically, I did this since I don't have .bash_profile:

  1. vi ~/.bashrc
  2. Added the following line of code at the bottom of the code: export GOPATH=$HOME/go