GoLand:不识别加载解析Go原生包
1.背景
使用GoLand时,由于一些需要(手欠),清理了GoLand的缓存:
然后,Project中的Go原生包,例如fmt.Println,居然标红不能被识别加载解析:
但是,如果在终端通过命令方式编译运行,则一切正常:(说明是IDE问题)
2.环境
go:
D:\test1280>go env
set GO111MODULE=auto
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\EB\AppData\Local\go-build
set GOENV=C:\Users\EB\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=D:\workspace\gopath\pkg\mod
set GONOPROXY=gitlab.xxx.com
set GONOSUMDB=gitlab.xxx.com
set GOOS=windows
set GOPATH=D:\workspace\gopath
set GOPRIVATE=gitlab.xxx.com
set GOPROXY=https://goproxy.io
set GOROOT=C:\Program Files\Go
set GOSUMDB=off
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.16.4
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=D:\test1280\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\EB\AppData\Local\Temp\go-build3457618426=/tmp/go-build -gno-record-
gcc-switches
GoLand版本:
GoLand配置:
3.解决
重新清理GoLand缓存,如下:
要勾选上图标红框复选项:Clear file system cache and Local History。
最终,GoLand可正常识别加载解析Go原生包: