Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Although GOPATH is set, echo $GOPATH returns nothing

Tags:

go

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?

like image 778
ethanchewy Avatar asked Jan 26 '23 20:01

ethanchewy


1 Answers

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.

like image 75
Sombriks Avatar answered Feb 12 '23 02:02

Sombriks