Background (win10 environment)
The installed go version is 1.14.3, and the installation path is D/basic_ tool/Go
The version of idea used is 2019.3.3
The configuration path of the system variable root is: D/basic_ tool/Go
The configuration path of the system variable gopath is: e/goprojects
The system variable Gobin value is% root%/bin;% GOPATH%/bin;
The correct configuration path is: D:: basic_ tool\Go\bin %GOROOT%\bin %GOPATH%\bin
On the window command line, enter the following command:
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
Then you can check whether the setting is successful through go env
The configuration path of root and gopath in idea is:
root: D/basic_ Tool/go
gopath: e/goprojects
gopath (global gopath and project gopath)
The configuration parameters of go modules (VGO) in idea are as follows:
Error Description:
The project placement path is: e/goprojects/SRC/xxx/gosvc/example
where gosvc is the name of the project and example is a subdirectory in gosvc, which contains multiple go files and a main.go file. Gosvc package and other packages under gosvc package are imported into main.go
file
The exception is that the gosvce package and the functions in the gosvc package are not recognized in main.go
No go files in D: Basic_ tool\Go\src\gosvc
Solution:
The system variable goproxy is set as shown in the figure below:
Delete the project gopath setting in idea, as shown in the figure below: