标签:版本 message exe 相对 文档 语言 pen hello 就是
因好奇而走进go语言,让你不在只闻其声,不见其形。
https://golang.org/doc/install;这里是go语言的官网文档。吃不透英文,终究会被限制在有限的区域,一词词的吃透。
安装包下载地址为:https://golang.org/dl/。
如果打不开可以使用这个地址:https://golang.google.cn/dl/。https://golang.google.cn/doc/install。
想了想,具体步骤就不提了,英文内容够全了。
说一下关于SettingGOPATH的中外差别:
就像原文所说,“ If no GOPATH
is set, it is assumed to be $HOME/go
on Unix systems and %USERPROFILE%\go
on Windows.”
那么这个GOPATH居然是在环境变量的用户变量中;
那么,原文中:
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.
C:\go-work
.GOPATH
into the "Variable name" field.C:\go-work
into the "Variable value" field.这段就是说将GOPATH这个环境变量的值由原来的%USERPROFILE%\go替换为你的go工作空间的目录。保存环境变量更改后,记得重启电脑是其生效(win10)。
原文中是这样使test.go生效的并测试的:
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.
但是,按旧有方式,还可在终端执行:go run hello.go
使用原文中的生成hello.exe文件得使用当前目录相对路径执行hello.exe这种方式。
标签:版本 message exe 相对 文档 语言 pen hello 就是
原文地址:https://www.cnblogs.com/louis95/p/12176246.html