1. "SECURITY ERROR This download does NOT match the one reported by the checksum server…"问题

笔者在使用GoLand进行依赖同步的时候遇到以下问题:

SECURITY ERROR This download does NOT match the one reported by the checksum server. The bits may have been replaced on the origin server, or an attacker may have intercepted the download attempt.

经过问题定位,有一个依赖没有同步成功:

git.code.xx.com/xxx/xxxxx-go

解决方案
方法1:打开GoLand Terminal,运行如下命令即可解决:

❯ go clean -modcache export GOSUMDB=off && go get git.code.xx.com/xxx/xxxxx-go

方法2:删除go.sum文件,重新进行Go Mod Tidy

2. "fatal: could not read Username … terminal prompts disabled"问题

问题分析:go.mod加载采用go get命令,go get 默认使用https拉取源码,缺少ssh用户权限,配置好git config即可:

解决方案
打开GoLand Terminal,运行如下命令(以Github为例):

❯ git config --global --add url."git@github.com:".insteadOf "https://github.com/"

3. MacOS "go:linkname must refer to declared function or variable"问题

报错信息:

../../../../go-mod/golang.org/x/sys@v0.0.0-20200116001909-b77594299b42/unix/zsyscall_darwin_amd64.go:28:3: //go:linkname must refer to declared function or variable
../../../../go-mod/golang.org/x/sys@v0.0.0-20200116001909-b77594299b42/unix/zsyscall_darwin_amd64.go:43:3: //go:linkname must refer to declared function or variable
../../../../go-mod/golang.org/x/sys@v0.0.0-20200116001909-b77594299b42/unix/zsyscall_darwin_amd64.go:59:3: //go:linkname must refer to declared function or variable
../../../../go-mod/golang.org/x/sys@v0.0.0-20200116001909-b77594299b42/unix/zsyscall_darwin_amd64.go:75:3: //go:linkname must refer to declared function or variable
../../../../go-mod/golang.org/x/sys@v0.0.0-20200116001909-b77594299b42/unix/zsyscall_darwin_amd64.go:90:3: //go:linkname must refer to declared function or variable
../../../../go-mod/golang.org/x/sys@v0.0.0-20200116001909-b77594299b42/unix/zsyscall_darwin_amd64.go:105:3: //go:linkname must refer to declared function or variable
../../../../go-mod/golang.org/x/sys@v0.0.0-20200116001909-b77594299b42/unix/zsyscall_darwin_amd64.go:121:3: //go:linkname must refer to declared function or variable
...
../../../../go-mod/golang.org/x/sys@v0.0.0-20200116001909-b77594299b42/unix/zsyscall_darwin_amd64.go:121:3: too many errors

解决方案:
打开GoLand Terminal,依次运行如下命令:

❯ go get -u golang.org/x/sys
❯ go build

即可完美解决。

4. go.mod文件右键无Go Mod Tidy选项

在这里插入图片描述
在这里插入图片描述
项目打开后go.mod文件右键无Go Mod Tidy命令,在Terminal运行该命令不能解决,设置 GO111MODULE = on 也无法解决,刚开始以为是GOPATH设置的问题,更改之后不起作用

解决方案
进入项目根目录,删除.idea文件重新打开即可

在这里插入图片描述
重新打开项目:
在这里插入图片描述
在这里插入图片描述
接下来进行Go Mod Tidy下载相关依赖即可

5. cannot find package"golang.org/x/sys/unix"问题

解决方案:

go get -u golang.org/x/sys

运行上述命令下载相应的包即可