设为首页 加入收藏

TOP

在IntelliJ IDEA14中安装go语言插件(一)
2017-09-30 13:56:03 】 浏览:6240
Tags:IntelliJ IDEA14 安装 语言 插件

go语言的集成开发环境仍不成熟,试用了liteide,感觉很不适应,弹出菜单对程序员的干扰太大。所以就试大牌的IntelliJ IDEA,这工具本来是JAVA开发阵营的,不过它已经变为一个非常强大的支持多种语言的集成环境了。

 

1、go环境

下载Go1.5.1(由于国内伟大的墙,golang.org访问被墙,搞点技术真是不易,从Golang中国的的百度云盘下载是不错的选择,http://pan.baidu.com/s/1hq1mrDM),安装很方便,直接解压到c:\go目录中即可。系统PATH环境变量中加上c:\go\bin。

2、IDEA

安装JDK1.8.0_60_x64,默认安装在C:\Program Files\Java目录下。安装IDEA时需要。

安装IntelliJ IDEA Community Edition 14.1.5到默认位置C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 14.1.5。

启动IDEA程序,在设置主题时,选Skip All and Set Defaults。工具装备就绪。

Clipboard_20151014

 

3、编译go-lang-idea-plugin插件

(不愿折腾这一步的朋友到这里下载我用1.0.0pre-release的build518编译生成好的jar文件:http://download.csdn.net/detail/slofslb/9182113,没办法有时要到CSDN下载点材料却没积分)

安装插件go-lang-idea-plugin,JetBrains官方的插件jar文件比较旧,所以到开源网站上找源代码自己编译后安装,这个插件的源代码从这个网址下载:https://github.com/go-lang-plugin-org/go-lang-idea-plugin/releases,直接下载的源代码master.zip中缺少idea的项目文件。我下载的是go-lang-idea-plugin--518.zip,我直接放在D:\go-lang-idea-plugin--518下。

用IDEA打开项目,也就是d:\go-lang-idea-plugin--518目录

Clipboard_20151014 (3)

此时会有git版本控制的警告,可以不管它,也可以关闭它。

此时直接编译,会报SDK不存在,要进行几项关键设置。

Clipboard_20151014 (4)

 

1)SDK设置

菜单File->Project Structure...,找到Platform Settings/SDK,点加号,加上JDK,选1.8,注意是JDK,而不是JRE,C:\Program Files\Java\jdk1.8.0_60。

再加上IntelliJ Platform Plugin SDK,就是它的安装目录:C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 14.1.5,Internal Java Platform绑定1.8。

再设置Project SDK: IntelliJ IDEA Community Edition IC-141.2735.5(java version 1.8.0)

Clipboard_20151014 (5)

Clipboard_20151014 (6)

 

2)Modules设置

此时进Project Settings/Modules的设置,应该 Module SDK使用了project SDK。

3)编译

再编译会有些警告,但编译成功!!!

4)生成jar

Build->Prepare All Plugin Modules For Deployment,成功后会在d:\go-lang-idea-plugin--518目录中生成了intellij-go.jar,我们需要的就是这一个宝贝。此时这个go-lang-idea-plugin--518项目的源代码就编译完成了,如果你不搞JAVA开发,以后就不用它了。

Clipboard_20151014 (7)

 

4、安装插件

进入IDEA的File->Settings->Plugin配置插件,install plugin from disk...,选intellij-go.jar文件,OK后,会提示重启Intellij IDEA。

5、在IDEA中开发go项目

new project,项目类型选go

比如d:\goproj\hello文件夹下,建立一个hello项目,提示你设置GO SDK,此时发现IDEA可以自动找到go1.5.1目录了。

在project里新建hello.go,运行时会有两种方式,一种对应于go build后运行,一种对应于go run。

package main
import "fmt"

func main(){
fmt.Println("hello world")
}
 
 
官网上给出新建idea中的go项目的方法:
https://github.com/go-lang-plugin-org/go-lang-idea-plugin/wiki/v1.0.0-Setup-initial-project

IntelliJ IDEA

  • create a new project by going to Create New Project | Go and follow the setup steps

Other IDEs

  • create a new blank project and you'll be prompted to setup a GO SDK for it

Once you've created the project according to your IDE, please follow the steps below

  • after your project has been created, you can then add your GOPATH packages to it so that you can use all the plugin features
  • to do, go to File | Settings | Languages & Frameworks | Go Libraries. Here you have a few options to choose from, but the recommended (and most tested one at the moment) is to create a new entry under Global Libraries that points to your GOPATH directory (see the example bellow). (强调要把项目主目录加到全局库中,可能这样就不需要设置GOPATH了?)
  • if you've followed the steps correctly, then "everything" should work for you

One concrete example would be (under Linux, paths may vary on other OSes):

  • GOROOT (aka sdk home) /usr/local/go
  • GOPATH (the path in Go Libraries | Global Libraries) /home/florin/golang/
  • project home /home/florin/golang/src/github.
首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇golang第一篇 下一篇Golang 并发简介

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目