Go into the language of curiosity, so that you are not only heard, but not its shape.
https://golang.org/doc/install ; here is the official website of the document go language. Not eat through English, it will eventually be restricted to a limited area, understand the word of the word.
Download the installation package is: https://golang.org/dl/ .
If you can not open this address: https://golang.google.cn/dl/ . HTTPS: // golang .google.cn / DOC / install .
I thought, not to mention the specific steps, the content of the English full enough.
Say something about the difference between Chinese and foreign SettingGOPATH of:
Like the original said, "the If NO GOPATH
IS the SET, IT IS ASSUMED to BE $HOME/go
ON Unix Systems and %USERPROFILE%\go
ON Windows."
Well, this is actually the user GOPATH variable environment variable;
So, the original text:
Your workspace can be located wherever you like, but we'll use C:\go-work
in this example.
NOTE: GOPATH
must not be the same path as your Go installation.
- Create folder at
C:\go-work
. - Right click on "Start" and click on "Control Panel". Select "System and Security", then click on "System".
- From the menu on the left, select the "Advanced systems settings".
- Click the "Environment Variables" button at the bottom.
- Click "New" from the "User variables" section.
- Type
GOPATH
into the "Variable name" field. - Type
C:\go-work
into the "Variable value" field. - Click OK.
This means that the GOPATH this environment variable values from the original% USERPROFILE% \ go with the source directory of your workspace go. After saving the environment variable changes, remember to restart the computer is its entry into force (win10).
The original text is in force and the test.go test:
Check that Go is installed correctly by setting up a workspace and building a simple program, as follows.
Create your workspace directory, %USERPROFILE%\go
. (If you'd like to use a different directory, you will need to set the GOPATH
environment variable.)
Next, make the directory src\hello
inside your workspace, and in that directory create a file named hello.go
that looks like:
package main import "fmt" func main() { fmt.Printf("hello, world\n") }
Then build it with the go
tool:
C:\> cd %USERPROFILE%\go\src\hello C:\Users\Gopher\go\src\hello> go build
The command above will build an executable named hello.exe
in the directory alongside your source code. Execute it to see the greeting:
C:\Users\Gopher\go\src\hello> hello hello, world
If you see the "hello, world" message then your Go installation is working.
You can run go
install
to install the binary into your workspace's bin
directory or go
clean
-i
to remove it.
Before rushing off to write Go code please read the How to Write Go Code document, which describes some essential concepts about using the Go tools.
However, according to the old way, but also in the implementation of the terminal: go run hello.go
Hello.exe text files generated in this manner have performed hello.exe relative path using the current directory.