GoLand2021.2.2无法找到go mod方式安装的依赖包<无法使用pkg/mod下的包>

运行go env:

set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Administrator\AppData\Local\go-build
set GOENV=C:\Users\Administrator\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=D:\go-workspace\16desktop\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=D:\go-workspace\16desktop
set GOPRIVATE=
set GOPROXY=https://goproxy.io,direct
set GOROOT=G:\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=G:\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.17.1
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=D:\go-workspace\16desktop\src\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\ADMINI~1\AppData\Local\Temp\go-build907008230=/tmp/go-build -gno-record-gcc-switches


1、在src目录下使用命令go mod init src新建 go.mod文件
2、goland中 file->Settings->Go->Go Modules中勾上 Enable Go Modules(vgo) integration

GOPROXY=https://goproxy.io,direct

GoLand2021.2.2无法找到go mod方式安装的依赖包<无法使用pkg/mod下的包>_第1张图片

3、在terminal中切换至src目录,运行go get -u <项目路径>

 

 

你可能感兴趣的:(golang)