安装指南
本指南将帮助你安装 WooCoo 及其相关工具。
系统要求
Go 版本
WooCoo 需要 Go 1.24 或更高版本。
- Linux / macOS
- Windows
验证安装
go version
# 输出: go version go1.24.x linux/amd64
环境配置
Go 模块代理(中国大陆用户)
# 设置 Go 模块代理
go env -w GOPROXY=https://goproxy.cn,direct
# 启用 Go 模块
go env -w GO111MODULE=on
安装 WooCoo
1. 创建项目
# 创建项目目录
mkdir myapp && cd myapp
# 初始化 Go 模块
go mod init myapp
# 安装 WooCoo
go get github.com/tsingsun/woocoo
2. 验证安装
创建一个简单的测试文件 main.go:
package main
import (
"fmt"
"github.com/tsingsun/woocoo"
)
func main() {
app := woocoo.New()
fmt.Println("WooCoo 版本:", app.Version())
}
运行测试:
go run main.go
安装 WoCo CLI 工具
WoCo(音:我可)是 WooCoo 的命令行工具,用于代码生成和项目初始化。
# 安装 CLI
go install github.com/tsingsun/woocoo/cmd/woco@latest
# 验证安装
woco -v
提示
安装后,确保 $GOPATH/bin 或 %GOPATH%\bin 在你的 PATH 环境变量中。
使用 CLI 快速开始
# 创建包含完整功能的项目
woco init -p myapp -m web,grpc,cache,otel -t ./myapp
# 进入项目
cd myapp
安装 gRPC 工具(可选)
如果你需要开发 gRPC 微服务,需要安装 Protocol Buffers 编译器。