Go Language Development environment configuration

Source: Internet
Author: User
Tags install go git client sublime text gocode

http://blog.csdn.net/hil2000/article/details/41261267/

I. Why should I learn the go language?

Today, in the era of mobile and cloud computing, go is a time when industry transforms into cloud computing, with simple, efficient, built-in concurrency primitives and modern standard libraries that make the go language especially suitable for cloud software development (after all, it is designed for this). By 2014, the Go project had hundreds of core contributors, with countless third-party libraries and tools (https://godoc.org/) in its ecosystem, and many large companies starting or migrating to the go language, some heavyweight open-source cloud projects, such as Docker and Kubernetes are all implemented in the go language, and some companies that operate the underlying settings, such as Google, CloudFlare, Canonical, Digital Ocean, Github, Heroku and Microsoft are also using the go language to develop some heavyweight projects. Take a look at the following company open-source Go library (1) Facebook Open source its go Library Https://github.com/facebookgo (2) Dropbox Open source its tool library based on the Go language Godropbox, It said that a year ago it was decided to migrate the back-end program with high performance requirements from Python to the go language. Almost all of Dropbox's code is written in Python, and the Python language is widely used in server-side, desktop-based clients, web-site control logic, and backend APIs and analytics. Dropbox pro-gaze python is easy to learn and highly developed, but now, in order to support the growing number of users, Dropbox has to replace some of the more demanding business with the go language with better concurrency support and faster run times. Go has been developed to version 1.4, with the exception of its new features and bug fixes, which lays the groundwork for implementing a new low-latency garbage collector and support for running go on mobile devices. As programmers we have to master a language while we need to broaden our horizons, learn the design ideas and the essence of another language, and I think go is the right one! 2015 will be a year of the big go language outbreak.

Two. Go language development environment building

Installation of 1.Go

(1) Download Go installer: https://golang.org/dl/(Wall http://www.golangtc.com/download), if your system is WINDOWS32 bit system, Please select Go1.3.3.windows-386.msi (2) after downloading directly double-click the MSI file installation, the default installation after C:\go (3) installation is completed by default in the environment variable Path after adding the Go installation directory of the bin directory C:\Go\bin\, and add environment variables Goroot, the value is Go install root directory C:\Go\ (4). Verify that the installation is successful, enter CMD in the Run command-line tool, enter Go (5) at the prompt to set the workspace Gopath directory (project path for Go language development) Windows settings are as follows, Create a new environment variable name is called Gopath, the value of your working directory, such as the author's settings Gopath=e:\mygo above the%gopath% directory Convention has three subdirectories: SRC storage source code (such as:. Go. C. h, etc.) pkg Files generated after compilation (e.g.. a) executable files generated after bin compilation (for convenience, you can add this directory to the path variable of windows, append%gopath%\bin after the environment variable path) (6) Use the Go ENV command to view environment variable settings

Selection and setting of 2.IDE
Go Development IDE currently has a lot of options, such as Liteide,vim,emcas,goeclipse, here is recommended sublime Text 2 (hereinafter referred to as sublime) +gosublime+gocode combination

(1) Download install sublime Text 2 http://www.sublimetext.com/(2) Install the Package Control Pack Management tool Ctrl + ' (the ~ key above the TAB key) Key to open Sublime2 command line (note IME mode is in English state), and then paste the following code to execute

[Python]View plain copy  < Span class= "Tracking-ad" data-mod= "popu_170" >
    1. 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

Then restart Sublime, you can find in the menu bar more than one of the following columns, that the package control has been installed successfully.

(3) Install the Gosublime plug-in ctrl+shift+p Open the package controll enter PCIP (that is, the ' Package Control:install package ' abbreviation), then enter Gosublime, Press OK to start the installation. (4) Same step (3) Install Go Build (5) Install Gocode code automatically prompt open Windows command line prompt program, start-"run-" cmd run the following code go get-u github.com/nsf/gocode Go install Github.com/nsf/gocode If you have an error message, install the GIT client (Windows git http://msysgit.github.io/, and then append the git configuration to the PATH environment variable;D: \ program Files\git\bin;d:\program Files\git\libexec\git-core;)

(6) Set the Go non-standard library smart Tips

The latest version of Gosublime requires you to set your Gopath variable into its configuration file, otherwise it may not be possible to support code entry hints for nonstandard library packages, open Settings-default, copy everything, and paste into settings-user (this practice is to ensure that your changes are not reset by plugin updates, which are frequently updated. Next, enter your Gopath variable in the Env field and restart the settings to take effect.

[Plain]View plain copy  
    1. "env": {
    2. "Goroot": "C:\\go",
    3. "Gopath": "E:\\mygo"
    4. },



Three. Write and run the Go program

1. Use sublime to create a new program Hello.go in the GOPATH/SRC directory, the code is as follows

2. Run the Go program Ctrl+b Open the Sublime command line and enter go run at the prompt hello.go

3. Compile and build EXE program Ctrl+b Open the Sublime command line and enter go build hello.go at the prompt

Four. Go language learning materials

1.go Guide: Official Website link: https://go-tour-zh.appspot.com/welcome/1 (need ladder), if unable to open please use domestic link: http://tour.studygolang.com/

2. "The way to go", if you feel the difficulty of reading English, on GitHub no smell Daniel has done a Chinese translation: Https://github.com/Unknwon/the-way-to-go_ZH_CN

3. The third edition of Go Learning notes, rain Marks, the ebook on GitHub open Source: Https://github.com/qyuhen/book

4. "Go Web Programming" is an ebook written by Matchmaker (Beego's author), the GitHub Chinese catalog link: https://github.com/astaxie/build-web-application-with-golang/blob/ Master/zh/preface.md

5. "Go Programming Basics" Video tutorial, this tutorial is a no-smell Daniel, github video link: https://github.com/Unknwon/go-fundamental-programming

Go Language Development environment configuration

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.