go set multiple GOPATHs
linux:
GOPATH="/home/www/gopath1:/home/www/gopath2"
windows:
GOPATH=f:/gopath1;f:/gopath2;
Notice:
When go get, install to the first GOPATH path by default.
When go build, sometimes the same type or method mismatch will be reported. Since multiple GOPATH paths are incorrect, you can solve the problem by changing the order.
Supplement: How to configure golang multiple projects (build projects under non-GOPATH path using gb)
Scheme 1: Write each project path to GOPATH
Write a script
#!/bin/bash if [[ $GOPATH =~ .*$PWD.* ]] then echo "currnet dir is already in GOPATH" else export GOPATH=$GOPATH:$PWD echo "fininsh setting $PWD in GOPATH" fi
Run source in the project home directory to write the current project path to GOPATH
Solution 2: Use gb instead of go to build a project
This gb is a tool that replaces Go build and test, which allows the project to run a build on any path
Github address:/constabula...
First, install this gb into GOPATH's src. If GOPATH has multiple paths, just install it in any path
Make sure your GOPATH is in PATH, so that you can call the gb command globally
The above is personal experience. I hope you can give you a reference and I hope you can support me more. If there are any mistakes or no complete considerations, I would like to give you advice.