Golang Development Environment Construction

Source: Internet
Author: User

Software Environment

Take the Windows environment as an example

1, Go1.3.3.windows-amd64.msi

Go Language installation package,:

Official address: https://golang.org/dl/

Golang China Address:http://www.golangtc.com/download

2, Git-1.9.4-preview20140929.exe

Git version management tool,Golang Many third-party packages are hosted on GitHub ,git combined with go Get can download the corresponding code package

: Http://git-scm.com/download/win

3, Ideaiu-13.0.2.exe

Idea for the Java integrated development environment, after installing the golang plug-in, can still be sharp to complete Golang Development work

: http://www.jetbrains.com/idea/download/

4. Sublime Text 2.0.2 x64 Setup.exe

Sublime Text is a powerful code editor, writing Golang code needs to install the corresponding plug- in

: http://www.sublimetext.com/

Development environment Construction

1. Install the go language Pack

Always Next,

2. Configure Environment variables

$GOROOT: point to Golang installation root directory,Windows Platform default c:/go (1 in install directory )

$GOARCH: processor architecture of the target platform (the compiled target platform) (386,amd64,arm)

Amd64:64bit X86

386:32bit X86

Arm:32bit Arm

$GOOS: The operating system of the target platform (the compiled target platform) (Darwin,FreeBSD,linux, Windows )

$GOBIN:golang the bin directory of the installation package

$GOPATH: Golang working directory, development and third party package root directory

Open computer, Right-click Properties , advanced system settings , Advanced systems, environment variables , add the corresponding environment variable

Goroot = C:\Go\

Goarch = AMD

GOBIN =%goroot%bin

GOOS = Windows

Gopath = D:\worksplace\go

Some environment variables are automatically configured after the go language Pack is installed,GOOS and goarch can be defaulted, and then GOBIN Add to PATH in the Go (install Go add automatically after language pack)

Run ->cmd Open terminal, enter go Simple Check whether configuration is complete

The above indicates a successful configuration

3. Construction of working directory structure

Property structure above,go directory is gopath directory, including bin,pkg and src three subdirectories to store tools, packages, and source code, respectively

4. Install git version management tool

Always next,finish

Run cmd input git to check if the installation is successful, if the command is not found, check to see if the git bin Directory is added to the the path environment variable

Once installed, you can use the go get command

Test go get github.com/astaxie/beego, after the command execution, look under the gopath directory src  directory, to see if the github.com/astaxie/beego directory is more, update the code will need to add - u, such as go get-u Github.com/astaxie/beego

5. Installation configuration Sublime text development environment

A) Install sublime Text 2

b)   installation package management tool  package control Span style= "font-family: the song Body;" >:  Open sublime2 ctrl +  " ->view->show console Open the console Enter the following command

Import Urllib2,os; Pf= ' Package control.sublime-package '; Ipp=sublime.installed_packages_path (); Os.makedirs (IPP) if not os.path.exists (IPP) else None; Urllib2.install_opener (Urllib2.build_opener (urllib2. Proxyhandler ())); Open (Os.path.join (IPP,PF), ' WB '). Write (Urllib2.urlopen (' http://sublime.wbond.net/' +pf.replace (', '%20 '). Read () ); print ' Restart Sublime Text to finish installation '

Enter

c) restart sublime2, you can find the proferences menu, more out of the menu item, the package Control

d) Press and hold the shortcut key CTRL + SHIFT + P or menu Preferences , the package Control Pop-up dialog box,

Enter package Install Enter, pop-up Pack dialog, and enter gosublime carriage return to install gosublime plug-in, same installation Go Build

e) Modify the gosublime configuration: under the Preferences menu, locate the package Settings, Then find the gosublime, and then find settings-defaultdown. Re-open the file, add the following configuration, and save

f) Configure ctagsto facilitate code tracing , install d Step installation ctags

Post - installation configuration menu Preferences under Package Setting CTags Setting-default

You need to download the ctags Software First, then configure

And can, in the code root right ctags:rebuild Tags, then you can select the variable or function, right-click on the definition of the place

6. Idea development Environment Construction

A) Install the idea package

b) Open idea, in the pop-up box, select Config-Setting, Plugins, select Install plugin from disk , select the google-go-language.jar plugin, and then restart

Plugin Download path: Http://plugins.jetbrains.com/search/index?pr=idea&search=golang

c) New project

Next

Next

Click Configure to select the Go Language Pack installation path

Next, select the src folder under the Gopath directory

Click Finish to complete

Idea and sublime According to personal preference, choose one.

Sublime text is relatively lightweight and faster

Idea's syntax hints are more intelligent and relatively suitable for beginners

Golang Development Environment Construction

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.