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原生包:


本文讲述了在GoLand中清除缓存后Go原生包无法识别的问题,通过重新设置和清理文件系统缓存解决,强调了IDE配置对Go开发的影响。
989

被折叠的 条评论
为什么被折叠?



