Skip to content
On this page

Go 快速开始

欢迎来到 Go 语言快速入门教程!

环境安装

首先需要安装 Go 开发环境:

bash
# 下载并安装 Go(访问 golang.org)
go version

第一个程序

创建 hello.go 文件:

go
package main

import "fmt"

func main() {
    fmt.Println("Hello, 世界!")
}

运行程序:

bash
go run hello.go

包管理

使用 Go Modules 管理依赖:

bash
# 初始化模块
go mod init example.com/myproject

# 添加依赖
go get github.com/gin-gonic/gin

下一步