这里以Windows7 64位为例,如果是32位环境需安装对应版本程序。
一、安装golang1.2.2
1.3及1.3.1编译生成的二进制文件,无法使用LiteIDE23.2携带的gdb7.7进行调试。
二、安装及配置LiteIDE
将liteidex23.2.windows.7z解压到D:\即完成安装。
2.1 设置编辑环境
因为是64位环境,所以选择“win64”。
查看->编辑环境变量,确认GOROOT变量与GO安装路径一致。

2.2 添加GOPATH
查看->管理GOPATH...,创建新目录E:\Code_Repository\golang,并添加到“自定义目录”。







三、安装及配置GoClipse
GoClipse是Eclipse的一个插件,当前0.8.0版本要求Java 7及Eclipse4.3

2.3 新建项目
选择上一步添加的GOPATH,模板为Go1 Command Project

编辑源代码,添加几行代码,包括变量声明、初始化及赋值,用来验证调试是否生效。

2.4 设置编译选项及编译
编译->编译配置,设置编译参数。在BUILDARGS添加-gcflags "-N -l",目的是去掉编译优化,方便调试。

Ctrl+B构建项目,生成hello.exe

2.5 调试程序
按F5启动调试,程序在main函数处停止

通过F10单步调试,可以看到i、j的变化(好像会稍微延迟那么0.X秒)

三、安装及配置GoClipse
GoClipse是Eclipse的一个插件,当前0.8.0版本要求Java 7及Eclipse4.3
3.1 安装jre-7u67-windows-x64.exe
GoClipse依赖CDT组件(应该调试时需要?),因此下载解压eclipse-cpp-luna-R-win32-x86_64.zip。
如果使用的是其它代码版本的IDE,还需要安装CDT组件。
3.3 安装GoClipse
2种方法:一种是通过Eclipse的Install New Software,另一种是直接下载GoClipse包解压到Eclipse目录。
方法1:
https://github.com/GoClipse/releases/raw/master/
记住:只将plugins和features两个目录解压到Eclipse目录即可,
千万别把其中的artifacts.jar和content.jar也放到Eclipse目录下,这会导致Preferences不显示Go配置项,即使删掉这两个文件重启也没用!
![]()

3.4 配置GoClipse

3.4 配置GoClipse
因为GoClipse及Eclipse都没有附带gdb和gocode,可以使用LiteIDE包中的这两个程序。解压liteidex23.2.windows.7z到D:\,后续配置时可以浏览到其中的文件。
也可以使用其它方式安装gdb和gocode,因为使用LiteIDE中程序是最方便的,其它方法就不介绍了。
Browse...浏览到Go的安装目录,Go Tools三个路径会自动填充。

目前0.8.0版本GoClipse没有提供build参数设置,为了方便调试程序,需要在编译时增加-gcflags "-N -l"取消优化。
可以通过bat文件对调用“Go tool path(go)”进行封装以提供build配置,创建批处理文件go.bat放置在go.exe所在目录。
假设调用的参数最多为5个(目前GoClipse中调用go好像只用build选项,下面的else分支似乎是不必要的)

修改“Go tool path(go)”为go.bat

配置gocode

3.4 新建项目
编辑源代码后保存,Eclipse默认自动构建项目,从Console可以看出调用的是go.bat build进行构建。

3.5 调试程序
按F11启动调试,界面好像没有什么响应,多按几次会显示以下窗口

这个时候Preferences才能看到GDB配置项(很神奇),“GDB debugger”浏览到LiteIDE中的gdb

配置在main函数启动处停止会以下提示信息,找不到源文件(这么奇葩的路径不知哪来的) 。

可以点击“Locate File..."浏览到Go安装包中对应的文件。

继续单步调试可以看到i、j值的变化

参考文档:
