In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
1. Install Go
Go to the official website of the Go language: http://golang.org/ and download the installation package for the corresponding platform. If it is an x86 system, you can download i386, if it is an x64 system, then install amd64. In addition, there are two kinds of installation packages for Go language under Windows: msi and zip. Zip is installation-free and can be used after some environment variables are configured, while msi is the version of the installation package, and the corresponding environment variables will be set during installation. For convenience, I downloaded the msi installation package on x64: go1.1.2.windows-amd64.msi. After installing the package, the installation process is very simple, and the next step will be fine in the end. Although msi automatically configures some environment variables, I still encounter the loss of some environment variables after installation, so after installing Go, we finally check whether some of the environment variables are normal. The main environmental variables are as follows:
GOROOT:Go installation directory
GOPATH: the directory used to store the Go language Package. This directory cannot be in the Go installation directory.
The directory where GOBIN:Go binaries are stored can be written as% GOROOT%\ bin
GOOS: operating system
GOARCH: specifies the system environment. I386 represents x86 and AMD64 represents x64.
PATH: you need to add% GOBIN% to the end of the PATH variable to make it easy to run Go on the command line
We can also use go env to view the definitions of all other environment variables
When the environment variables are configured properly, Go is installed. Now open the command line, run go, and you should see the following prompt.
2. Hello Go!
Let's do Hello World now!
Package mainimport "fmt" func main () {fmt.Println ("Hello, World!")}
Save the above program as hello.go, and then execute it on the command line:
Go run hello.go
Tada! The result will come out!
And the Go language can also compile go programs directly into exe and then publish them, which is more convenient than python (you need to use py2exe). You only need to run it on the command line:
Go build hello.go
You can see and execute the compiled exe.
In addition, we can also see that this hello.exe is as much as 1.5m, which should be because go packages the entire virtual machine into exe. From the point of view of exe's dependence, he is completely independent of go and has only a few system dll.
3. IDE
With regard to IDE, everyone has different preferences. You can use the more independent development environment LiteIDE, which can be VS or Eclipse, or even notepad++, not to mention vim and emacs. Here, I introduce two of the more common IDE:LiteIDE and Eclipse.
3.1. LiteIDE
LiteIDE is a very good integrated Go IDE, compiling, debugging, code completion, it can be said to have everything. It's also free, open source, and based on QT, so it's cross-platform. Its installation is extremely simple. Download the installation package for the corresponding platform from the official website (https://code.google.com/p/liteide/), and then extract it to the specified directory.
3.2. Eclipse + GoClipse
Eclipse is a very famous IDE, so I won't say much about how to install it. I'll give you a brief introduction to the process.
Download and install the latest JRE on http://java.com/
Download the latest Eclipse from http://www.eclipse.org/ and decompress it.
The Eclipse you just downloaded does not support Go. In order to make it support the Go language, we need to install a plug-in: GoClipse.
Project address: https://code.google.com/p/goclipse/
The installation process is very simple, just add a source to Eclipse: http://goclipse.googlecode.com/svn/trunk/goclipse-update-site/, then select GoClipse, and install it, as shown in the following figure.
After installation, restart Eclipse, and we can use Eclipse to write programs in the Go language.
3.2.1. GoCode
When writing code with GoClipse, we will find that there is no code completion, in order to increase code completion, we need to install gocode. LiteIDE is not needed because it already has gocode built in.
GoCode is host on github, using go to write to do go language code completion project, the project address is: https://github.com/nsf/gocode, which has a very detailed installation method. Because go has built-in tools similar to the package manager, the installation is simple.
Install git: because you need to use git during installation, you need to install msysgit or cygwin first. If you find this troublesome, there is an easier way to install github for windows: http://windows.github.com/.
Start git shell and run: go get-u-ldflags-H=windowsgui github.com/nsf/gocode.
Now take a look at the% GOBIN% directory and you will find that there is gocode.exe.
Next, you need to configure Eclipse. Open Windows- > Preferences, find the Go- > Gocode tag, and set the path to gocode.exe.
It's done. Now write the code.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.