go开发工具goclipse的安装 - Go语言中文社区

go开发工具goclipse的安装


(1) 安装Eclipse

建议下载Eclipse时直接下载“Eclipse IDE for Java Developers”的package,而不要下载较小的Installer。因为Installer在安装Eclipse时还要联网下载,因为***的原因,联网下载会非常慢甚至失败。
Eclipse package下载地址:http://www.eclipse.org/downloads/eclipse-packages/

(2) 安装GoClipse

可以采取在线安装的方式或离线的方式安装。
我采用在线安装的方式可以安装成功,如果因为网络的原因,可选离线安装方式。
GoClipse安装指南:https://github.com/GoClipse/goclipse/blob/latest/documentation/Installation.md#installation

Start Eclipse, go to Help -> Install New Software...
Click the Add... button, then enter the Update Site URL: http://goclipse.github.io/releases/ in the Location field, click OK.
Select the recently added update site in the Work with: dropdown. Type GoClipse in the filter box. Now the Goclipse feature should appear below.
Select the GoClipse feature, make sure "Contact all update sites during install to find required software" is enabled, and complete the wizard.
Dependencies such as CDT will automatically be added during installation.

(3) 配置GoClipse

  • 在Eclipse中,打开Windows -> Preferences,找到Go,在Go installation中输入Go SDK的C:\Go目录。
    在C:\Go目录下创建一个子目录,比如work,在Eclipse GOPATH中输入C:\Go\work。

c398585b867a378c5bfcb81bffc3932a.PNG
下面会在C:\Go\work这个目录下编译Go的其它工具。

  • 打开Go -> Tools。对gocode和godef可以点击Download按钮来从GitHub直接下载。

2ce2c91ef3663ee8388e2b1eea35e02b.PNG
但是对guru,直接Download会失败,因为Download时试图去从Golang官网下载,而Golang官网已经被拉黑了。
不过因为Golang的代码都是托管在GitHub上的,所以我们可以通过下面的地址来下载Go tools的源代码。
https://github.com/golang/tools
下载后,在C:\Go\work\src目录下创建golang.org/x的目录结构,并将上一步git clone的Go tools的tools目录复制到golang.org/x目录下。

 git clone https://github.com/golang/tools.git

719e9e853401acb03c60fab56f865b81.PNG

  • 在C:\Go\work\bin目录下,在命令行中执行(以GitBash为例)

792b90a1c4db712773e09d1ace081cb0.PNG

export GOPATH="C:\Go\work"
go build golang.org/x/tools/cmd/guru

161e200c4b26ce384b8e5001459839c6.PNG

/c/Go/bin/go.exe build golang.org/x/tools/cmd/guru

1b7ca513e6d696362b85699baa7e4c3f.PNG

88291e68d345edb116c632ddffac9937.PNG
执行命令成功后guru.exe就会生成在C:\Go\work\bin目录下。

  • 最后在Eclipse中设置好guru。

    d52eec96b1647ef5c965fe3311ba056e.PNG

  • 在Eclipse中写第一个Go程序

    在Eclipse中新建一个Go project,再在src下创建一个hello目录,再在hello目录下新建一个hello.go的Go file。内容如下所示:

85f0f8d9209f9f9f6c0da6fa618932c6.PNG
右键Run as -> Go Application。

如果出错“Executable … doesn’t exist“,请检查hello.go的第一行是否为package main,Go需要从main package作为程序入口,这一点和Java程序是不同的。

参考文章:

使用Eclipse和GoClipse作为Go开发IDE

转载于:https://www.cnblogs.com/zouke1220/p/10070407.html

版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/weixin_30485379/article/details/94851895
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2023-01-03 21:07:28
  • 阅读 ( 366 )
  • 分类:Go

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢