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