Should GOPATH? be set separately for each project in go language?

go language: should GOPATH? be set separately for each project
for example, my go project is managed uniformly under the d:/workspace/go_work/ directory, where there are three items project_01 , project_02 , project_03 :

d:/workspace/go_work/project_01
d:/workspace/go_work/project_02
d:/workspace/go_work/project_03

question:
1. Should I set 3 GOPATH , separated by semicolons? Like this:

d:/workspace/go_work/project_01;d:/workspace/go_work/project_02;d:/workspace/go_work/project_03

2. Do you want to add 100 items to GOPATH ?

Nov.05,2021

you can choose to set more than one, either one project, one gopath
or one gopath to include multiple items. As mentioned above


No, directly set GOPATH=d:/workspace/go_work


you can set one. If you need to introduce other packages in the project, you can use vendor this function


GOPATH. Your project_01 can be placed in the src directory, so that you don't need to set
2 every time. Your project_01 is placed anywhere, as long as it is not under GOPATH. The premise for using go mod, is that your go version is 1.11


No, and all projects can be set to only one gopath, or set separately to a different gopath.


for each project.

No, there is only one gopath on a system (a user).

The

gopath/src/ project should be placed here.
gopath/pkg/ is managed by go and stores some intermediate compilation results.
gopath/bin/ is used to store the software program, go install will compile and copy the project here, and then you can call it directly on the command line.

Future go versions with the use of gomodule, gopath is about to become obsolete, and the project is no longer dependent on gopath.


1 GOPATH is fine, and then many items are in it. For example, mine is like this:


  go echo $GOPATH
/Users/xxxx/go

  go tree -L 2 $GOPATH
.
 bin
  bee
  beeHello
  cobra
  dlv
  fillstruct
  geth
  geth-tps
  glide
  go-outline
  go-symbols
  gocode
  goconvey
  godef
  godoc
  golint
  gomodifytags
  gopkgs
  goplay
  gorename
  goreturns
  gotests
  govendor
  guru
  hi
  impl
  puppeth
  rlpdump
 pkg
  darwin_amd64
 src
     awesomeProject
     beeHello
     github.com
     golang.org
     gopkg.in
     govendor
     sourcegraph.com
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5480b-452bf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5480b-452bf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?