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

在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.

图片转代码服务由CSDN问答提供 功能建议

好的,所以只是免责声明,我怀疑这个问题会与另一个问题重复,但是我什至不确定 搜索什么。

我以前从未使用过Eclipse或Golang,并试图使基本的hello world应用程序正常工作。

我已经安装了goclipse插件, 创建了一个新的go包和go命令源文件。 从我在Eclipse中运行项目所读到的内容中,右键单击该包,选择Run as,然后设置运行配置。 当我尝试选择go软件包时会出现问题,因为没有一个出现,如果我将其保留为空白,则会引发“找不到Go软件包”异常。

“在此处输入图片描述” < p>谢谢您能提供的任何帮助。

编辑:根据答案建议,我决定使用基本命令行,但是朋友也推荐使用LiteIDE。 我将“假设” tmichels的回答对于使Eclipse在Go内工作是正确的。

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

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.

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题