zoukankan      html  css  js  c++  java
  • 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:Gowork。


    下面会在C:Gowork这个目录下编译Go的其它工具。

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


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

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

    • 在C:Goworkin目录下,在命令行中执行(以GitBash为例)

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

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


    执行命令成功后guru.exe就会生成在C:Goworkin目录下。

    • 最后在Eclipse中设置好guru。

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


    右键Run as -> Go Application。

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

    参考文章:

    使用Eclipse和GoClipse作为Go开发IDE

  • 相关阅读:
    <C> 链表 双向链表 栈 队列
    <C> 结构体
    <C> getchar()函数 如何把getchar()到的字符串存起来的实际应用
    DataSet转换为泛型集合和DataRow 转成 模型类
    对DataSet,DataRow,DateTable转换成相应的模型
    Json对象与Json字符串互转(4种转换方式)
    Android开发 使用HBuilder的缓存方法
    MIT_AI公开课p1p2学习笔记
    LeetCode_02 两数相加【链表】
    leetcode_01两数之和
  • 原文地址:https://www.cnblogs.com/zouke1220/p/10070407.html
Copyright © 2011-2022 走看看