Go语言入门到精通------安装和Hello World
文章目录
- [Go语言入门到精通------安装和Hello World](#Go语言入门到精通——安装和Hello World)
- 下载并安装
- 让Go跑起来
- 为你的代码启动依赖跟踪
- 调用外部包
- 总结
下载并安装
下载地址:https://go.dev/dl/
下载后傻瓜式安装
查看是否安装完成
bash
go version
让Go跑起来
- 创建一个这样的目录和文件:
- 写一个这样的代码:
go
package main
import (
"fmt"
)
func main() {
fmt.Println("Hello, World!")
}
- 在目录下这么运行一下:
bash
go run main.go
- 然后得到:
bash
Hello, World!
- Go的帮助:
bash
go help
为你的代码启动依赖跟踪
在命令行输入:
bash
go mod init example/hello
调用外部包
go
package main
import (
"fmt"
"rsc.io/quote"
)
func main() {
fmt.Println(quote.Go())
}