This is a creation in Article, where the information may have evolved or changed.
Configuration of Golang under Linux
Before the development of Golang has been under Windows, today under the Linux test, encountered some stems, such as go can not find the sync package. It took an hour to get it all settled, to record the process.
Install Go
My system is Ubuntu, completely can be installed with Apt-get, simple and convenient, but so after the installation of the above mentioned cannot find the Sync pack problem. After uninstalling the already installed go, choose to download the installation package from the official website.
Download address Select the appropriate installation package, I chose go1.6.1.linux-amd64.tar.gz. Then create a folder in your system to put the installation package, and then use wget add download address, the installation package to download to the built folder. Then type TAR-XZF go1.6.1.linux-amd64.tar.gz to unpack the installation package into the already-built folder.
A Go folder appears after decompression, and a bin folder under go. Use the ln-s (Soft Connect command) to chain the executable files under the bin to the/usr/bin, go and gofmt. You can now view the go version directly by typing the go versions command.
Configuring the Environment
Set Goroot First: export GOROOT=你建好的文件夹地址\go
. The reason for setting up Goroot is that the system looks for a standard library when compiling the project. The official website also has steps to add path, this is to facilitate the system to find the go, Godoc and gofmt three executables, but this problem has been resolved through a soft connection.
Compiling the first HelloWorld server
First build a project folder, set the Gopath variable to point to this folderexport GOPATH=刚建的文件夹路径
Create a bin,src,pkg Three folder under this folder. src folder for the third-party library files, pkg Decentralized is compiled library files (. A suffix file)
Set the GOBIN environment variable export GOBIN=$GOPATH\bin
. (The Go Install command needs to place the executable file in the directory specified by Gobin)
Create a package main file you can download this source file HelloWorld use wget to download to the folder you just created
Type the go get command to automatically install the dependency package into the SRC folder, the Helloworld.go source code of the third-party dependency package on GitHub, the installation will not be problematic. (But make sure Git is installed)
Type go build to compile the project, without error, you can have an executable file with the same name as the previously built folder to execute the file. Then type the access address in the browser:你的机器的ip:8080/hello
Run
Server-side
Client
The client uses the node. js to make an HTTP GET request