Golang Study Notes-ide Installation Guide

Source: Internet
Author: User
Tags gocode

Introduction

Golang Study notes-environment building Guide has explained how to build Golang development environment, and wrote a go program "Hello,world", but write code does not have a good IDE, no syntax highlighting, automatic completion, format adjustment, find functions and other functions, It's going to make everyone crazy, I used to do Java and. NET development, often with the IDE has eclipse, IntelliJ idea and Visual Studio, where Eclipse and IntelliJ idea can install a lot of plug-ins, Naturally think of the eclipse and IntelliJ idea can be installed to support the Go Language development plug-ins, search plug-ins are really, nonsense said, directly into the IDE installation process.

IntelliJ idea installs the Go language plugin

First you install good IntelliJ idea, the specific installation process here does not table, do not understand please Baidu, the author's idea version is 2017.1.5

Idea Version

Click "File"-"Settings"

Menu

Select "Plugins"-"Install jetbrains plugin ..."

Install plugins

Enter "Go", select "Go Languages", then click "Install", need to note that this is only supported go 1.9 version, the author installs the 1.11 version, using the plugin is not compatible.

Install

Restart idea when the installation is complete

Restart idea

After reboot select "File"-"New"-"Module"

New module

Now you can see that you can create a Go language project, but we also need to configure the SDK here, choose the Go installation directory

Create Go projectnew Module

The next step is to set Gopath, which is actually the working directory of Go

Gopath.png

Because I installed the 1.11 version of Golang, so did not specifically test the plug-in is available, in fact, jetbrains for the Go language specifically developed a Ide,goland

Installing Goland

First go to the Goland download page Download the latest version of the IDE, the author downloaded the 2018.2.2 version, download completed directly after installation, installed after the input license can start using the

Goland

If you have previously developed Java using IntelliJ idea, you will find that Goland shortcut keys are as easy as IntelliJ idea to get started.

Liteide

Liteide is a simple, open-source, cross-platform, Go language IDE. The download address is available on the Soureceforge

Download Liteide

The author download is 34.1 of the Windows version, after the download is finished directly decompression can be extracted after double-click the bin directory liteide.exe, open the first set up the editing environment, because I use the 64-bit operating system, so the environment select Win64, and then choose "Tools"-"edit the current environment 】

Tools-edit

Set the installation directory for Goroot to Golang

Goroot

Then set Gopath, choose Tools-Manage Gopath

Tools-managegopath

After setting up, you can start to use, auto-complete, format adjustment and other functions have

Liteide

Eclipse Install Goclipse Plugin

You can refer to the official installation guidance document to open the document and you will see several restrictions

    1. Java Virtual machine requires more than 8;
    2. Eclipse needs 4.6 (Neon) above, the author uses 4.7 (Oxygen);
    3. CDT requires more than 9.0 (CDT can be pre-installed or installed when Goclipse is installed)

Pay attention to the official documents most issued, for the Chinese user wrote, in order to prevent due to the existence of GFW caused by the lack of connection, timeout or slow network, we recommend the use of offline installation.

    1. First download the Goclipse offline package, unzip after the download is complete.
    2. Then open eclipse, click on "Help"-"Install New software ..."-"Add", fill in the plugin description, and click "Local" to select the downloaded resource package extracted "release" directory, click "OK"
Add Repository

If the CDT is already installed, only Goclipse is selected here, if not installed, you need to select the first three items: CDT Main Features, CDT Optional Features, and Goclipse, then keep Next until the end of installation

Install Goclipseinstall Detailslicense

After the installation is complete restart Eclipse, open is the configuration, select "Window"-"performances"-"Go", set goroot, that is, go to the installation directory, you must first click on the "Apply" app.

Set Goroot

Then select "Go"-"Tools", set Gocode, Guru, godef, click Download directly, the popup box will appear, click "OK" directly

Set Toolsdownload Gocode

This installs the Discovery guru cannot download, because GFW causes us to be unable to access golang.org this site, the Eclipse console window returns the message as follows:

>> Running: "C:\Program Files\Go\bin\go.exe" get -u github.com/nsf/gocode
>> Running: "C:\Program Files\Go\bin\go.exe" get -u golang.org/x/tools/cmd/guru
>> Running: "C:\Program Files\Go\bin\go.exe" get -u github.com/rogpeppe/godef
package golang.org/x/tools/cmd/guru: unrecognized import path "golang.org/x/tools/cmd/guru" (https fetch: Get https://golang.org/x/tools/cmd/guru?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
   ^^^ Terminated, exit code: 1 ^^^
   ^^^ Terminated, exit code: 0 ^^^
   ^^^ Terminated, exit code: 0 ^^^

We can download the guru source code and compile the corresponding. exe file using the Go build instructions.
First download the entire project, and then in the Go installation directory "src" directory to create a new multilevel directory "Golang.org\x\", then unzip the downloaded zip package in the "src\golang.org\x\" directory, and the folder name from " Tools-master "Change to" tools "

Tools Directory

Then open the cmd command line in the bin directory of the Go installation directory and execute the following command

go build golang.org/x/tools/cmd/guru

After successful execution, the "Guru.exe" file is generated in the "Bin" directory, and the directory of the Guru tool I configured is "D:\Go\bin\guru.exe", so I cut this file into the "D:\Go\bin\" directory

Guru

At this point, all the configuration is completed, the following can be tested, a new Go project, or Hello World code, you can see the auto-completion of these features, right-"Run as"-"Go Application" try, you can see the correct output Hello, world !

Hello World

It is important to note that there must be a main package below SRC

Summarize

    • IntelliJ idea temporarily does not support go 1.9 above version, so is excluded, estimated will not support, because JetBrains launched the Goland;
    • Goland for the previous use of IntelliJ idea developed Java Program Ape is not unfamiliar to use, all kinds of shortcut keys, and support syntax highlighting, automatic completion, breakpoints and other functions, easy to use;
    • Liteide is very light, and also support syntax highlighting, automatic completion, automatic format adjustment and other functions, but I feel the breakpoint is not convenient, do not support Click or double hit breakpoint, you need to move the cursor to a line, and then click the Breakpoint button, the other temporarily did not find, and so the use of a period of time to supplement;
    • Eclipse installation plugin is troublesome, but it is very convenient to use, basic and development Java almost;

But I still feel the best use of Goland.

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.