du127953 2014-12-29 19:58
浏览 48
已采纳

在golang示例中运行测试时“不允许导入周期”

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条回答 默认 最新

  • dpbv85276 2014-12-29 20:07
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?