Golang Learning Journey: Building The Go language development environment

Source: Internet
Author: User
Tags sublime text

From today onwards, you will learn the go language. Today, I turned a brief introduction to "Go Language programming" written by Xu Xiwei predecessors: Go language-C language in the era of cloud computing. Many of the features of the go language are described in the preceding sequence, very powerful, eager to find out, and then ask the go language. It is fortunate to find that the master of the No-sniff has recorded a set of introductory tutorials for beginners in the go language, thanks! Here's the tutorial.

The official website is: https://golang.org/(er, very innocently blocked, way to see here)

This is the homepage of the official website introduction. The Go programming Language

Go is a open source programming language that makes it easy-to-build simple, reliable, and efficient software.

Not much nonsense, take the environment first.

1 Installing the Development Kit

There are two ways to install, one is binary, and one is source code.

Here under Windows I chose the binary mode installation. On the download page https://golang.org/dl/select Go1.4.2.windows-amd64.msi download.

After the download is complete, the next step is to install it in one click, and the C:\Go directory will be installed by default under Windows.

When installed, you will find that a "C:\Go\bin" is automatically appended to your PATH environment variable, and an environment variable is added to represent your installation directory: goroot=c:\go\.

Enter the bin directory under the installation directory (C:\Go\bin) to see three tools, as follows:

Then enter go at the command line to detect if the installation was successful, and the following information can be output if the installation succeeds:

C:\users\michael>GoGo is a tool formanaging Go source code. Usage:go command [arguments]the commands are:build compile packages and dependencies clean Remo veObjectFilesEnvPrint Go Environment information fix run Go tool fix on PackagesFMTrun GOFMT on package sources generate generate Go files by processing source get download an DInstallPackages and DependenciesInstallCompile andInstallPackages and Dependencies list List packages run compile and run Go program test test Packages tool run specified Go tool version print go version vet run Go tool vet on Packagesus E"go Help [command]"  for  Moreinformation about a command. Additional help Topics:c calling between Go and C filetypefiletypes Gopath gopath environment variable importpath import path syntax packages description of Pack Age lists Testflag description of testing flags TestFunc description of testing FunctionsUse"go help [topic]"  for  MoreInformation about that topic.

You can see that go has a lot of commands, and here you see the output of Go env first:

C:\users\michael>goEnvSet Goarch=AMD64 #CPU架构set GOBIN=#工作目录下的文件夹set Gochar=6Set Goexe=. exe #生成可执行文件的后缀set gohostarch=Amd64set Gohostos=Windowsset GOOS=Windowsset Gopath=#工作目录set Gorace=Set Goroot=C:\Go #安装目录set Gotooldir=C:\Go\pkg\tool\windows_amd64set CC=GCCSet Gogccflags=-m64-mthreads-fmessage-length=0Set CXX=g++Set cgo_enabled=1

Can see the system's environmental information, the above working directory Gopath has not been value, and manually go to Windows to establish an environment variable named Gopath, and set the working path.

You can also use the Godoc command to view the doc document locally: Type the following command at the command line: c:\users\michael>godoc-http=:8080 this time the command lines are blocked and then entered in the browser http://localhost:8080/ To view the document, note that if you close the command-line window at this point, you will not be able to view the document in the browser (that is, you want to see the document, you must keep the name running in a blocked state).

2 Installing the IDE

Here I am using Sublime Text 2 + gosublime.

Download Sublime Text 2 and install.

After opening Sublime Text 2, press the shortcut key Ctrl + ' to open the Command window line, ' This button is on the TAB key. Enter the following and return to:

Import Urllib2,os; pf='Package Control.sublime-package'; Ipp=sublime.installed_packages_path (); Os.makedirs (IPP)ifNot Os.path.exists (IPP)ElseNone; 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'

After restarting Sublime Text 2, it is possible to find a menu item under the Preferences menus with the package Control.

Now that the Gosublime plugin is installed, pressing and holding ctrl+shilft+p will pop up a dialog box, enter install Enter to pop up an installation package dialog box. Then enter Gosublime to select Gosublime carriage return.
Done, Gosublime installed successfully. Reboot.

3 Helloword

Open Sublime Text 2, New Helloworld.go

After writing and saving, pressing the shortcut key below the Ctrl + B interface will appear as follows:

Enter Go build hello.go

Run the output and finish!

Resources

Https://github.com/Unknwon/go-fundamental-programming

http://blog.csdn.net/love_se/article/details/7754274

Http://www.cnblogs.com/youyou/archive/2013/04/14/3020137.html

Golang Learning Journey: Building The Go language development environment

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.