本文目录
- go语言开发环境哪个版本最稳定
- 如何配置go语言集成开发环境 vim
- eclipse配置go
- 如何更加便捷地在Eclipse上开发GO语言
- 如何在win7环境下搭建Go开发环境
- ubuntu下怎么配置go语言开发环境
go语言开发环境哪个版本最稳定
一般来说比最新版本低两个版本就好。现在可以用1.18版本。1.18版本已经更新了泛型
如何配置go语言集成开发环境 vim
1、编译vimgdb 下载vimgdb73和vim73 mkdir -p ./tmpcd tmptar zxvf ../vim-7.3.tar.gzunzip ../vimgdb-for-vim7.3-master.zipmv vimgdb-for-vim7.3-master vimgdb-for-vim7.3patch -p0 《 vimgdb-for-vim7.3/vim73.patchcd vim73安装依赖 sudo apt-get install build-essentialsudo apt-get build-dep vim-gtksudo apt-get install libncurses5-dev安装 // 这里直接执行make的操作makesudo make install安装vimgdb runtime cd ../vimgdb-for-vim7.3cp vimgdb_runtime ~/.vim/bundle打开vim :helptags ~/.vim/bundle/vimgdb_runtime/doc " 生成doc文件添加配置.vimrc " vimgdb插件run macros/gdb_mappings.vim在vim中执行gdb时,报 “Unable to read from GDB pseudo tty” 的错误,因为没有安装 gdb ,所以安装gdb sudo apt-get install gdb2、安装vundle set up vundle***隐藏网址***Configure Plugins 在.vimrc文件的开头添加下面的内容,有些不是必须的,可以注掉 set nocompatible " be iMproved, requiredfiletype off " required" set the runtime path to include Vundle and initializeset rtp+=~/.vim/bundle/vundle/call vundle#rc()" alternatively, pass a path where Vundle should install plugins"let path = ’~/some/path/here’"call vundle#rc(path)" let Vundle manage Vundle, requiredPlugin ’gmarik/vundle’" The following are examples of different formats supported." Keep Plugin commands between here and filetype plugin indent on." scripts on GitHub reposPlugin ’tpope/vim-fugitive’Plugin ’Lokaltog/vim-easymotion’Plugin ’tpope/vim-rails.git’" The sparkup vim script is in a subdirectory of this repo called vim." Pass the path to set the runtimepath properly.Plugin ’rstacruz/sparkup’, {’rtp’: ’vim/’}***隐藏网址***Plugin ’L9’Plugin ’FuzzyFinder’" scripts not on GitHubPlugin ’git://git.wincent.com/command-t.git’" git repos on your local machine (i.e. when working on your own plugin)Plugin ’file:///home/gmarik/path/to/plugin’" ...filetype plugin indent on " required" To ignore plugin indent changes, instead use:"filetype plugin on"" Brief help" : PluginList - list configured plugins" : PluginInstall(!) - install (update) plugins" : PluginSearch(!) foo - search (or refresh cache first) for foo" : PluginClean(!) - confirm (or auto-approve) removal of unused plugins"" see :h vundle for more details or wiki for FAQ" NOTE: comments after Plugin commands are not allowed." Put your stuff after this lineInstall Plugins Launch vim and run : PluginInstall vim +PluginInstall +qall3、官方vim-lang插件 Config vim file .vimrc,Add content bellow in bottom of the file " 官方的插件" Some Linux distributions set filetype in /etc/vimrc." Clear filetype flags before changing runtimepath to force Vim to" reload them.filetype offfiletype plugin indent offset runtimepath+=$GOROOT/misc/vimfiletype plugin indent onsyntax onautocmd FileType go autocmd BufWritePre Fmt4、代码补全的插件gocode 配置go的环境变量,比如我的配置,GOPATH变量是必须要配置的,PATH中必须把GOPATH的bin也添加进去,否则没有自动提示,会提示找不到模式 export GOROOT=/usr/local/goexport GOPATH=/data/app/gopathexport PATH=$PATH:$GOROOT/bin:$GOPATH/binSet up gocode Then you need to get the appropriate version of the gocode, for 6g/8g/5g compiler you can do this: go get -u github.com/nsf/gocode (-u flag for "update")Configure vim in .vimrc file Plugin ’nsf/gocode’, {’rtp’: ’vim/’}Install Plugins Launch vim and run : PluginInstall vim +PluginInstall +qall写一个helloword程序,输入fmt后按《C-x》《C-o》如果能看到函数的声明展示出来,说明安装是正确的。 4、代码跳转提示godef Set up godef go get -v code.google.com/p/rog-go/exp/cmd/godefgo install -v code.google.com/p/rog-go/exp/cmd/godef***隐藏网址***Configure vim in .vimrc file Bundle ’dgryski/vim-godef’Install Plugins Launch vim and run : PluginInstall vim +PluginInstall +qall5、代码结构提示gotags Set up gotags go get -u github.com/jstemmer/gotagsPut the following configuration in your vimrc: Bundle ’majutsushi/tagbar’nmap :TagbarTogglelet g:tagbar_type_go = { \ ’ctagstype’ : ’go’, \ ’kinds’ : , \ ’sro’ : ’.’, \ ’kind2scope’ : { \ ’t’ : ’ctype’, \ ’n’ : ’ntype’ \ }, \ ’scope2kind’ : { \ ’ctype’ : ’t’, \ ’ntype’ : ’n’ \ }, \ ’ctagsbin’ : ’gotags’, \ ’ctagsargs’ : ’-sort -silent’ \ }
eclipse配置go
1.下载go的windows下的安装包:
***隐藏网址***
也可以下载源代码,用MinGW编译。先配置好MinGW的环境,再运行all.bat即可。
***隐藏网址***
2.下载gocode,用于go的补全提示:
gocode 的github地址:
***隐藏网址***
要安装git,在windows下,通常用msysgit。
***隐藏网址***
再在cmd下安装:
go get -u github.com/nsf/gocode
也可以下载代码,直接用go build来编译,会生成gocode.exe。
3.在eclipse中安装插件:
***隐藏网址***
4.配置插件:
(1).配置go的编译器
(2).配置gocode(可选),这里我用的是eclipse插件自带的gocode。
(3).配置gdb,做调试用(可选)
如果安装了MingW,可以在安装目录下找到gdb。
5.测试是否成功
新建一个go工程,再建立一个hello.go。如下图:
gdb调试如下(要在console中用输入命令来调试):
6.其它
2012年3月31日:
目前这个eclipse插件,只能把代码放在cmd包中才能运行。
貌似现在流行的是Sublime Text2 + gocode。Sublime Text也的确比较好用。
======================
***隐藏网址***
Eclipse平台下配置Go语言开发环境(Win7)
《Go语言编程》中写到:“从功能和易用性等方面考虑, Eclipse+GoEclipse、LiteIDE这两个环境在所有IDE里面是表现最好的”,所以笔者打算采用Eclipse+GoEclipse开发环境。
Eclipse平台下配置Go语言开发环境步骤:
1、安装JDK和Eclipse
建议JDK1.6及以上版本。Eclipse3.6及以上版本。
2、安装GoEclipse插件
***隐藏网址***
按提示一步一步操作即可,下载时可能会遇到网络问题,可使用goagent或其他代理。
3、安装并配置Go的编译器
***隐藏网址***
下载时请注意版本,应选择windows-386的版本。
安装完后重启Eclipse,并通过菜单项“Window”-》“Preferences”-》“Go”打开Go语言的配置选项框。如下图:
选择Go的安装路径即可,如笔者的安装路径是F:\Work\Go
4、配置调试器(可选)
***隐藏网址***
安装完之后,通过菜单项“Window”-》“Preferences”-》“Go”-》“Debugger”打开调试器的配置选项框。
将GDB路径配置为:MinGW安装目录下的gdb.exe文件即可。
5、配置代码自动补全(可选)
***隐藏网址***
笔者使用的是goEclipse插件自带的版本,配置方式如下:
通过菜单项“Window”-》“Preferences”-》“Go”-》“Gocode”打开配置选项框。
将Gocode的路径配置为:goEclipse的安装路径下的gocode.exe文件,如
F:\Work\eclipse\plugins\com.googlecode.goclipse.gocode_0.7.6.v450\tools\windows_386\gocode.exe
6、配置支持Import远程包(可选)
***隐藏网址***
"fmt"
"github.com/astaxie/beedb"
_ "github.com/ziutek/mymysql/godrv"
为了编译该a.go文件,需要启动Console.bat,然后在该命令行窗口,进入c:\go\src目录下,执行go getgithub.com/astaxie/beedb
Go get github.com/ziutek/mymysql/godrv .
Go 会自动下载该远程包并编译和安装这些包。
7、go install: no install location for directory *** outside GOPATH错误的处理
由于每一个Go程序都必须包含一个main包以及一个main()函数,因此如果没有main包就会导致上述错误。
What Doesn’t Kill Me Makes Me Stronger
如何更加便捷地在Eclipse上开发GO语言
方法如下: 1.下载安装GO的包 2.设置环境变量 在“我的电脑”中配置GO的环境变量: 2.1新建环境变量 GOROOT,值为所解压的GO的根目录 2.2在PATH环境变量中添加GO的bin 2.3打开cmd命令行,输入 go。如果配置正确,则会有帮助提示。
如何在win7环境下搭建Go开发环境
首先需要下载下载go平台安装包安装程序 下载地址址h如果是您的系统是windows32 位系统请选择go1.3.3.windows-386.msi即可,其他的,请按照自己所需版本来进行下载,如下图所示:安装以及配置环境变量由于Windows下的的安装包有两种:msi和zip的;zip的是免安装的,解压在配置一些环境变量之后就可以使用,msi的则是安装包版本的,安装的时候会设置好对应的环境变量。我的电脑是Win7 64位,因为方便,就下载了下面的版本。下好安装包后,安装过程就很简单了,一路“Next”就好了。 虽然msi会自动配置一些环境变量,但是本人在安装完之后还是自己配置了环境变量,所以在安装完Go之后,我们最好还是检查一些所有的环境变量是否正常。主要的环境变量有以下几个:GOROOT:Go的安装目录GOPATH:用于存放Go语言Package的目录,这个目录不能在Go的安装目录中GOBIN:Go二进制文件存放目录,写成%GOROOT%\bin就好GOOS:操作系统GOARCH:指定系统环境,i386表示x86,amd64表示x64PATH:需要将%GOBIN%加在PATH变量的最后,方便在命令行下运行Go如下图所示:像我自己安装的,下载完成之后解压到任意目录(所有目录均不能使用中文):D:\Go;然后是go环境变量的配置:GOARCH:386(go安装版本)GOBIN:D:\Go\bin(exe执行文件路径)GOOS:windows(go运行的系统)GOROOT:D:\Go(go的解压路径)GOPATH:E:\go\data(go的工具包路径,随意指定,后面会用到)然后在path环境变量中追加:;%GOBIN%完成之后在cmd窗口输入:go version,如下图所示:
ubuntu下怎么配置go语言开发环境
具体步骤:
1、去官网下载go1.1.2的tarball,一般下载到tem目录
2、打开终端cd /usr/local, tar -zxvf go1.1.2.linux-386.tar.gz
将源码文件解压缩到/usr/local目录,如果解压到其他目录,需要自己设置GOROOT
3、安装gcc工具,因为golang有些功能是使用c写
sudo apt-get install bison gawk gcc libc6-dev make
4、$ cd go/src,$ ./all.bash
运行bash脚本,如果运行正常会获得你的操作系统和cpu信息,自动编译安装
5、将export PATH=$PATH:/usr/local/go/bin 写入$HOME/.profile
最后进行测试输入go version 会显示go1.1.2 linux/386