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's open-source go Library
(1) Facebook Open source its go library Https://github.com/facebookgo
(2) Dropbox opens up its tool library Godropbox based on the go language and says it has decided a year ago to migrate back-end programs 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 to
(2) After download directly double-click MSI file installation, installed by default in C:\go
(3) After the installation is complete, the environment variable Path is added to the bin directory under the Go installation directory C:\Go\bin\, and the environment variable goroot is added, and the value is the Go install root directory C:\Go\
(4). Verify that the installation is successful, enter CMD in the Run Open command line tool, enter go at the prompt
(5) Set Workspace Gopath directory (project path for Go language development)
Windows settings are as follows, a new environment variable name is called Gopath, and the value is your working directory, such as the author's settings Gopath=e:\mygo
The above%gopath% directory Convention has three subdirectories:
SRC store source code (e.g.,. Go. C. h, etc.)
The files generated by the PKG after compilation (for example:. a)
Executable file generated after bin compilation (for convenience, you can add this directory to the path variable in Windows and append%gopath%\bin to 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) Installing the Package Control Pack management tool
Ctrl + ' (the ~ key above the TAB key) to open the Sublime2 command line (note that the IME mode is in English state), and then paste to execute the following code
[Python]View Plaincopy
- 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) Installing the Gosublime plug-in
Ctrl+shift+p Open the Package controll input PCIP (the abbreviation for the "package Control:install"), then enter gosublime and press OK to start the installation.
(4) Same step (3) Install Go Build
(5) Install Gocode code automatic prompt
Open the 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;)
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