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 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘