英文:
"import cycle not allowed" while running test in golang example
问题
我正在尝试为我的 Golang 函数设置测试,但在控制台运行 go test ...
时遇到以下错误:
import cycle not allowed package runtime
imports unsafe
imports runtime
我以为是我的问题,所以我克隆了golang 示例项目并运行了 go test reverse_test.go
,但是得到了相同的错误。
我的 GOPATH
和 GOROOT
环境变量的值都设置为 C:\go
,这是我安装 Go 的位置。
我使用的是 Windows 8.1 64 位机器。
有什么想法是出了什么问题吗?
英文:
I'm trying to setup tests for my functions in golang, but getting the following error while running go test ...
from the console:
> import cycle not allowed package runtime
> imports unsafe
> imports runtime
Thinking that it was me I cloned the golang example project and ran go test reverse_test.go
, but getting the same error.
Both my GOPATH
and GOROOT
environment values are set to C:\go
, where I installed Go.
I'm on a Windows 8.1, 64bit machine.
Any ideas what's wrong?
答案1
得分: 3
确保在将GOPATH设置为正确路径后执行"go get github.com/golang/example/hello"(如github.com/golang/example中所述)。
请参阅" 如何编写Go代码 ":
GOPATH环境变量指定工作区的位置。在开发Go代码时,这可能是您唯一需要设置的环境变量。
您应该在$GOPATH/src
中看到您的github/golang/example
。
英文:
Make sure to do a "go get github.com/golang/example/hello
" (as mentioned in github.com/golang/example) once your GOPATH is set to a proper path.
See "How to Write Go Code":
> The GOPATH
environment variable specifies the location of your workspace. It is likely the only environment variable you'll need to set when developing Go code.
You should see your github/golang/example
inside $GOPATH/src
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论