douchuang1852 2015-01-24 05:00
浏览 224
已采纳

在Eclipse中运行Golang Hello World问题

Alright, so just a disclaimer I suspect this question will be a duplicate of another question however I'm not even sure what to search for.

I have never used Eclipse or Golang before and am attempting to get a basic hello world application to work.

I have installed the goclipse plugin, created a new go package and go command source file. From what I have read to run a project in Eclipse you right click the package, select Run as then set the run configurations. The problem occurs when I attempt to select the go package as none shows up and if I leave it blank it throws a 'Go package not found' exception.

enter image description here

Thank you for any help you can provide.

EDIT: Upon the answers advice I have decided to go with the basic command line, however a friend did also recommend LiteIDE. I will "assume" tmichels answer is correct in regards to getting Go to work within eclipse.

  • 写回答

1条回答 默认 最新

  • duanmiexi2275 2015-01-24 12:21
    关注

    If you don't use the GOPATH environment variable and you don't put your project folder under $GOPATH/src the compiler won't find it. As I see it goclipse lets you skip the GOPATH entirely but in this case you have to put your code under the src directory that you can see in the Project Explorer. See the related section of the goclipe documentation.

    Although I think you make your life harder by using a full-fetched IDE for go development. Just use the command line tools. And it has the added benefit that you will actually understand what's going on (IDEs hide this from you).

    So for building you can use go build or go install. The latter will copy the binary to your $GOPATH/bin directory. For running test just call go test or go test path/to/package. There is a hidden gem in the go tool: when you are working with multiple packages in the same directory you can use go test ./... to test all of them at once. This also works with other go commands.

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

报告相同问题?

悬赏问题

  • ¥15 gwas 分析-数据质控之过滤稀有突变中出现的问题
  • ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
  • ¥15 知识蒸馏实战博客问题
  • ¥15 用PLC设计纸袋糊底机送料系统
  • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
  • ¥15 用C语言输入方程怎么
  • ¥15 网站显示不安全连接问题
  • ¥15 51单片机显示器问题
  • ¥20 关于#qt#的问题:Qt代码的移植问题
  • ¥50 求图像处理的matlab方案