This is a creation in Article, where the information may have evolved or changed.
Windows uses Eclipse+goclipse plug-in +gdb to build the Go Language development debugging environment
Http://rongmayisheng.com/post/windows%E4%B8%8B%E7%94%A8eclipsegoclipse%E6%8F%92%E4%BB%B6gdb%E6%90%AD%E5%BB %bago%e8%af%ad%e8%a8%80%e5%bc%80%e5%8f%91%e8%b0%83%e8%af%95%e7%8e%af%e5%a2%83
At present go language on Windows or Linux operating system, the best Go Language development debugging environment is built by Eclipse+goclipse plug-in +gdb. If you have not yet set up a development environment for the Go language, please refer to this blog post, "Installation and development environment for go language under Windows".
Generally everyone with eclipse is the development of Java, if you want to develop go, it is necessary to install the Goclipse plug-in, so as to have code highlighting, automatic compilation, Lenovo hint, jump to function definition and other rich features, if you want to debug the function, you have to have GDB If you also want to introduce an open source library on GitHub, you need a git client. Here is a description of the installation and use:
Installing Goclipse
Before installing the goclipse, you need to install the jdk8 beforehand. Goclipse Download Address:http://goclipse.github.io/releases/ , because I am facing the high wall exists, may this address is unstable, even some people can not access, recommended reference Goclipse official documents, Download the contents of the releases directory to the local and unzip, using the local path as a URL to install, such as: file:///D:/goclipse.github.io-master/releases/, Java installation Eclipse plug-ins should be familiar with the installation process is relatively simple, direct point next, accept, yes, restart Eclipse can be (perhaps due to domestic speed, the installation process may be longer). If the installation is successful, you can see go in the Tree menu on the left side of the window–>preferences, click Go, and then set the Goroot path to the Go installation directory on the right, and the following path to the Go tool will be automatically recognized. You should see the following effect at this point:
Below to create a go project to test, in the menu bar file–>new–>other–> Select go–> Choose Go project–>next–> give the project a name (such as Gotest) –> Finish, create a success, and then create a source file with the main entry function in the SRC directory of the project test.
Configure GBD
Create a source file with the main function
Then edit the code to see the effects of highlighting and code hints
Golang Code Association
The effect is good, goclipse now has a very good support for method hints, AutoComplete, and view method variable declarations, and these features are not configured as an extra, because Goclipse contains a gocode (auto-complete tool for Go language) , the Gocode is installed automatically when the Goclipse is installed (for example: my Gocode in D:\software\green_software\eclipse-j2ee\eclipse\plugins\ COM.GOOGLECODE.GOCLIPSE.GOCODE_0.7.6.V439\TOOLS\WINDOWS_AMD64), so gocode generally does not require additional installation and configuration, just tick to let it start automatically when Eclipse starts, The configuration path is: Window->perferences->go->gocode, so that when eclipse is started, you can see the gocode process in the list of processes in Window Explorer. Such as:
Gocode Configuration for Goclipse
If you do not have gocode, or if Gocode does not start up, or if you want to use the latest Gocode, you can start the gocode manually before starting eclipse by using the following command:
Gocode.exe-s-sock=tcp
This allows you to use dot numbers in eclipse to associate methods and fields, and to automatically complement methods and fields with alt+/.
There are two ways to run this program, one is the CD into the bin directory of the project, execute the following automatic link good exe file, and the other is the right key on eclipse the source file where the main function –>run as–>run Go application, can be.
I usually in the process of use, found a strange problem, is that their code can not be automatically compiled and can not run, research only to find that the project src directory configuration is not correct, in theory this configuration does not need to manually match, but if you also encounter this situation, you can see this SRC directory is configured correctly , see the picture you know:
Check the project configuration after the newly introduced Go Project
Installing GDB
Think about it, if the code cannot be debugged, it can only be done through FMT. PRINTLN ("xxx") this way, that is how painful ah, let own development environment can be dynamic debugging is very necessary. Below is an introduction to how to install and configure GDB to let Eclipse support the Go language code for picky eaters.
Because the go compiler compiled executable program is according to GDB Standard, so currently debugging go language code must have GDB, need to install one in Windows, Linux is easy to install GDB, but Windows more trouble, more common practice is to install MINGW, Then use the gdb inside. But I recommend another approach:
Download another with GDB's Go language integration development software Liteide(green software, unzip it), the inside of the bin directory has Gdb.exe and Gdb64.exe, the former two files for 32-bit operating system, the latter for 64-bit operating system.
Then put your operating system corresponding to the GDB configuration into the Goclipse plug-in, the operation as follows:window–>preferences–> open the Go node –> select Debug, and then set GDB, my operation is 64-bit, So I chose the gdb64.exe.
Configure GDB
This will be OK, now you can try to set a breakpoint in the code to see the effect. (Of course, the debug function is not so perfect now, but most of the time it is possible to dynamically view the value of the variable, some of which can only be done in the way of output.) )
Configuring the Gopath Variable association go SDK source code
If you do not use Eclipse+goclipse, and use Notepad to write code, you have to configure Gopath, although the use of goclipse can not set the Gopath environment variables, but that will not be directly associated with eclipse to see the source of go. If you want to choose a function in your own code, and then press F3 (or ctrl-click a function) to see the source (the functionality of Eclipse's common code), you need to configure Gopath for Goclipse, and then you can hold down the CTRL key to a function. You can jump to go to the source code directly to see the implementation of the source code, which is very helpful for learning go, strongly recommend everyone to use. Configure effects
Setting up Gopath in eclipse
After the configuration is over, you can see that there is a Goroot node in Project Explorer, this node is the source of go, nothing more look good!
Use git to download third-party libraries
Because GitHub is very hot now, many open source enthusiasts have their own code hosted on GitHub, BitBucket, Google Code, the go language itself is open source. Students who want to learn the go language will inevitably go to these places to see the good code written by others, but it is best to download the code to play with them. To download the code you need to use a GIT client, which allows you to download the code and package it with simple commands. So you can use it conveniently. Below is a description of the download and installation of the following GIT client:
The Windows client download address for git is: http://code.google.com/p/msysgit/downloads/list?q=full+installer+official+git
There is one step to be aware of during the installation process, which allows you to use GIT commands on the DOS command line, which makes it easier to
git installs, so your git commands can be used in the Windows console
At this time you can use the GIT command on the Windows command line, now try to look good to use no, I have an open source toolkit on BitBucket, with this as an example to try ~ ~
First CD into the SRC directory of your project, and then type this command: Go get-u bitbucket.org/weager/utils
The-u in this command will automatically update the package when you have downloaded it. At this time, should be able to see the bitbucket.org directory in the SRC directory, which has a weager directory, this directory is utils package code.
Then run the package command: Go install bitbucket.org/weager/utils
At this point in the PKG directory generated in the same SRC directory, in the Utils directory there will be a UTILS.A file, which is the package generated after the file. See figure:
The Go project directory structure and the downloaded package
Once you have downloaded the package, you can use it in your project, such as:
Introduction of third-party library code demo in Go language code
So far, the go language development environment is complete, and you can start developing, good luck
Reference
Eclipse and other IDE's go language development environment building
Goclipse Installation
Original article: Under Windows with Eclipse+goclipse plug-in +GDB build Go language development debugging environment, reproduced please specify: Reproduced from Rong code life
Post Footer automatically generated by Wp-posturl plugin for WordPress.