Go Environment Building

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed. installation under Windows system

Windows can be installed under an installation package that uses the. msi suffix (which can be found in the download list for the file, such as Go1.4.2.windows-amd64.msi).

By default, the. msi file is installed in the C:\Go directory. You can add the C:\Go\bin directory to the PATH environment variable. You will need to restart the Command window to take effect after adding.

Installation test

Create the working directory C:\>go_workspace.

File name: Test.go, the code is as follows:

 PackageMainImport "FMT"Func main() {FMT.Println("Hello, world!.")}

Use the GO command to execute the above code output as follows:

C:\go_workspace>Go Run test.GoHello,  World!

Build Go development and debug Environment (Liteide + goclipse)--Windows


  First, install the Golang 1.3 and 1.3.1 Compile the generated binaries and cannot be debugged using the gdb7.7 carried by LiteIDE23.2. (.......... Ben Wang is under the 1.5. It seems to be able to use ...)



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

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.