因好奇而走进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.

  • 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.

这段就是说将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这种方式。

更新:

1. 因为go version >= 1.13,所以go env -w GO111MODULE=on修改相应依赖模式,go env查看

最新文章

  1. 【软件工程】“谁是卧底”之NABC分析
  2. spring mvc 工作流程
  3. Sass关于颜色函数的乐趣
  4. 3.Android 优化布局(解决TextView布局)
  5. maven仓库私服配置
  6. 《高质量C++/C编程指南》陷阱 【转】
  7. android 应用架构随笔一(架构搭建)
  8. 第二百零九天 how can I 坚持
  9. JSTL标签总结
  10. setImageResource和setImageDrawable区别
  11. 根据权限显示隐藏SharePoint 2010快速启动栏的链接
  12. spring mvc + mybatis + spring aop声明式事务管理没有作用
  13. Photoshop 钢笔 双窗口显示
  14. js实现键盘按键检测
  15. 在MinGW下编译ffmpeg
  16. 【源码解析】Sharding-Jdbc的执行过程(一)
  17. 将博客搬至CSDN https://blog.csdn.net/Fredric_2014
  18. Django 之 admin管理工具
  19. 使用 RAII 完成线程等待
  20. C#服务端Web Api

热门文章

  1. android中的简单animation(二)push up,push left,cross fade,hyperspace
  2. maven详解 之仓库
  3. POJ 2287 田忌赛马
  4. 《分布式消息中间件实践》P153
  5. java第三周
  6. .Net 经典案例
  7. 洛谷 三月月赛 C
  8. 机器学习(ML)一之 Linear Regression
  9. JavaWeb高级编程(下篇)
  10. 【CS224n-2019学习笔记】Lecture 1: Introduction and Word Vectors