Go language Compiler detailed

Source: Internet
Author: User
Tags gdb debugger gocode
This is a creation in Article, where the information may have evolved or changed.

Here, take Windows7 64-bit as an example, if the 32-bit environment needs to install the corresponding version of the program.

First, install the golang1.2.2

1.3 and 1.3.1 Compile the generated binaries and cannot be debugged using the gdb7.7 carried by LiteIDE23.2.



Second, installation and configuration Liteide

Unzip the liteidex23.2.windows.7z to D:\ to complete the installation.

2.1 Setting up an editing environment

Because it is a 64-bit environment, select "Win64".

View the edit environment variable to confirm that the Goroot variable matches the go installation path.

2.2 Adding Gopath

View Management Gopath ..., create a new directory E:\Code_Repository\golang, and add it to the custom directory.


2.3 New Project

Select the Gopath that you added in the previous step, and the template is Go1 Command Project


Edit the source code and add a few lines of code, including variable declaration, initialization, and assignment, to verify that debugging is in effect.


2.4 Setting compilation options and compiling

Compile-and-compile configuration, set compilation parameters. Add -gcflags "-n-l"in Buildargs to eliminate compilation optimizations and facilitate debugging.


Ctrl+b build the project, build the Hello.exe


2.5 Debugging Programs

Press F5 to start debugging, the program stops at the main function


With F10 single-step debugging, you can see the changes of I and J (as if it were slightly delayed by 0. X seconds)




Third, installation and configuration Goclipse
Goclipse is a plugin for eclipse, the current 0.8.0 version requires Java 7 and Eclipse4.3


3.1 Installing Jre-7u67-windows-x64.exe

3.2 Downloads Unzip the eclipse IDE for C + + developers

Goclipse relies on the CDT component (should be required when debugging?) ), so download the decompression eclipse-cpp-luna-r-win32-x86_64.zip.

If you are using a different code version of the IDE, you will also need to install the CDT component.

3.3 Installing Goclipse

2 ways: One is through Eclipse's install New software, and the other is to download the Goclipse package directly to the Eclipse directory.

Method 1:

https://github.com/GoClipse/releases/raw/master/



Method 2:https://github.com/goclipse/releases Click on the "Download ZIP" in the lower right corner

Remember : Extract only the plugins and features two directories to the Eclipse directory,

Do not put Artifacts.jar and Content.jar in the Eclipse directory, which will cause preferences to not show go configuration items, even if the deletion of these two files restart is useless!



3.4 Configuring Goclipse

Because both Goclipse and eclipse do not come with GDB and Gocode, you can use both of these programs in the Liteide package. Unzip liteidex23.2.windows.7z to D:\, and you can browse to the files in the subsequent configuration.

GDB and Gocode can also be installed in other ways because it is most convenient to use the Liteide program, and other methods are not introduced.

Browse ... Browse to the Go installation directory and the Go Tools three paths will be populated automatically.

Currently 0.8.0 Version Goclipse does not provide a build parameter setting, in order to facilitate debugging the program, you need to add-gcflags "-n-l" de-optimization at compile time.

You can use the bat file to encapsulate the call "go tool path" to provide a build configuration and create a batch file Go.bat placed in the directory where Go.exe resides.

Assuming that the parameters of the call are up to 5 (currently called Go in Goclipse, it seems to use the build option only, the next else branch appears to be unnecessary)

Modify "Go tool path" to Go.bat

Configure Gocode

3.4 New Project

After editing the source code to save, Eclipse automatically builds the project by default, as you can see from the console that the Go.bat build is being called.

3.5 Debugging Programs

Press F11 to start debugging, the interface seems to have no response, more than a few times will show the following window

This time preferences can see GDB configuration items (very magical), "GDB debugger" Browse to GDB in Liteide

Go back to the source editor and press F11 to restart debugging.

The configuration stops at the start of the main function with the following message and cannot find the source file (so the path is not known where).

You can click "Locate file ..." to browse to the corresponding file in the go installation package.

You can see the changes of I and J values by continuing with single-step debugging

Reference Documentation:

Https://github.com/GoClipse/goclipse/blob/latest/documentation/Installation.md#installation

Http://www.infoq.com/cn/articles/use-liteIDE-develop-go


Original address: http://www.cnblogs.com/custa/p/3913526.html
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.