From JAVA to Go -- Go in eclipse

Source: Internet
Author: User
Tags gocode

This is because the high concurrency of the go coroutine attracts me.

And google language. I believe that he will develop well in the future. So let's take a look.

Of course, language is a virtual thing. The main thing is the understanding of programming thinking.

Therefore, I do not recommend learning the syntax of a language and learning another language. It is best to spend enough time studying a language. It is mainly about programming patterns.

Okay. Let's talk about how to build go on eclipse.


1. Just like java has to have jdk first. First install the go Language Pack. : Http://code.google.com/p/go/downloads/list? Q = OpSys-Windows + Type % 3 DInstaller

Is an MSI executable file. Double-click to install it.

Note that the installation directory cannot contain Chinese characters. (Select the default one)

Then the environment variable needs to be set.

GOROOT is the installation path, and the default installation path is c: \ Go.

PATH needs to append the following bin directory, C: \ Go \ bin

GOPATH is equivalent to the eclipse workspace, Which is set in a file according to your preferences.

This contains three directories. Src put the source code, pkg (I am not clear yet), bin stores the compiled results. All three files are created by yourself.

After installing the go Language Pack, set the environment variables. At this time, go can be compiled and run.

Create a test. go file. Write in

package mainimport "fmt"func main() {    fmt.Printf("hello, world\n")}
Run cd in the cmd command line and go run test. go in the directory of this file.

Then the go program is compiled and run.



2. Add the go language plug-in to eclipse <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + signature + zb/J0tS00834yc/PwtTYsLLXsMHLoaM8L3A + CjxwPjxpbWcgc3JjPQ = "http://www.2cto.com/uploadfile/Collfiles/20140405/20140405091011244.jpg" alt = "\">

Restart eclipse after installation.


3. Set the go Environment

In eclipse window ---> Preferences ---> Go

Just fill in goroot gopath.



4: skip this step if you do not need Alt +/code reminders.

The Code reminder is to be supported by a gocode project. Download go and compile it to generate the exe file.

I generate a connection for gocode.exe: http://download.csdn.net/detail/u012565107/7147335

If the latest version is required, download it and compile it. Git: https://github.com/nsf/gocode

Download the source code to the src directory of GOPATH.

Then run go build gocode

Gocode.exe is generated under the current directory.

Set this gocode.exe in the window ---> Preferences ---> Go ---> gocodeof eclipse.

A code reminder is displayed after the code is saved.


5. Now you can create a new GoProject.

Put the test. go you just wrote under src to continue the test.

Right-click test. go run as --> run go application


Now, Hello, world is successfully started.

After building the platform, I will continue to learn about go...

I wish you success.

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.