Go 学习完整指南
Go 学习完整指南 本文档整合了 Go 官方学习资源 (go.dev/learn/) 和 Go by Example (gobyexample.com) 的全部内容,提供完整、可用、可重复学习的 Go 语言参考资料。 第一部分:Go 官方学习资源 1.1 Go 入门教程 (Getting Started) 来源:https://go.dev/doc/tutorial/getting-started 本教程快速介绍 Go 编程基础,包括安装 Go、编写 “Hello, World”、使用 go 命令运行代码、调用外部模块函数。 前提条件 有一定的编程经验 代码编辑器(VSCode、GoLand、Vim 等) 命令行终端 安装 Go 从 https://go.dev/dl 下载并安装最新版本(Go 1.26.5)。 编写第一个程序 # 创建工作目录 mkdir hello cd hello # 初始化模块 $ go mod init example/hello go: creating new go.mod: module example/hello hello.go — 第一个 Go 程序: package main import "fmt" func main() { fmt.Println("Hello, World!") } # 运行程序 $ go run . Hello, World! 调用外部包 使用 rsc.io/quote 包中的函数生成更有趣的输出: ...