Skip to content

Latest commit

 

History

History
120 lines (88 loc) · 3.43 KB

File metadata and controls

120 lines (88 loc) · 3.43 KB

Hello CLI Developer Onboarding

Purpose: capture the project context from docs/prompt.md and make it easy for new contributors to ramp up without losing any of the original hand-written details.

1. Why We Chose Go

维度 Go Rust .NET AOT C/C++ Node (pkg)
单文件静态 exe CGO_ENABLED=0 需 zig-cc / LLD ✔ 但 >5 MiB ✔ 手工繁琐 ✔ 体积 60 MiB
交叉编译 一行环境变量 工具链复杂 官方组合少 各装 SDK 有缺口
构建生态 goreleaser cargo-release MSBuild 脚本 无统一 手写
Hello.exe 体积 1.7 MiB (UPX 700 KiB) 300 KiB 5-6 MiB 30 KiB 60 MiB
新手曲线 15 min 陡峭 内存管理 最平
AV 误报 极低

结论

  1. 开发效率 + 产物体积 + 生态模板 三要素,Go 综合最优。
  2. 初学门槛极低,强劲对手难以在短期内提供“更优解”。

与 README 的 “Why Go” 表格保持一致,必要时在此补充额外的对比数据。

2. 开发设备与基础依赖

2.1 macOS(主开发机)

brew install go git goreleaser gh upx
brew install --cask cursor       # GUI IDE(可选,但与原手册一致)

2.2 Windows 11(验证 / winget 工具链)

winget install -e --id Git.Git
winget install -e --id Microsoft.WingetCreate   # GUI & CLI
winget install -e --id GoReleaser.GoReleaser
winget install -e --id Cursor.Cursor            # 可选 IDE

3. 任务管理(Linear 看板示例)

  1. 创建 Team:HelloCLI
  2. Milestone:v1.0.0 上架 winget
  3. 初始 Issue 模板:
- 编写 main.go 打印 Hello, world!
- 配置 goreleaser(windows amd64/arm64)
- 创建 GitHub repo hello-cli 并推送
- 打 tag v1.0.0 -> 触发 Release
- 编写 winget manifest (Moniker=hello)
- 提 PR 到 winget-pkgs
- 在 Win11 终端验证 `winget install hello-cli` 并运行 `hello`

维持线性流:代码 → 发布 → 分发 → 反馈。完成后将卡片拖动到 Done 列。

4. 最小可行产品(MVP)

4.1 初始化仓库

mkdir hello-cli && cd hello-cli
git init -b main
go mod init github.com/<your-gh-user>/hello-cli

4.2 基础实现

package main

import "fmt"

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

4.3 交叉编译校验

GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -o hello.exe -ldflags "-s -w"
upx hello.exe   # 可选压缩

5. Go 速查表(10 分钟上手)

// 读取 CLI 参数
name := "world"
if len(os.Args) > 1 {
    name = os.Args[1]
}
fmt.Printf("Hello, %s!\n", name)

// 彩色输出
import "github.com/fatih/color"
color.Cyan("Hello, %s!", name)

交叉编译更多示例:GOOS=linux GOARCH=arm64 go build -o hello.

6. 完成清单 ✅

  • macOS 安装 Go / GoReleaser / Cursor
  • Windows 安装 WingetCreate / Cursor
  • GitHub 仓库推送并打首个 tag(例如 v1.0.0)触发 Release
  • winget manifest (Moniker=hello) PR 合并
  • winget install hello-cli 成功运行并输出问候 (hello)
  • Linear 看板任务全部移动到 Done
  • 对外宣传(推文 / Hacker News)附带截图 🎉

现在你了解了团队为何选择 Go、如何配置开发环境,以及如何完成 Hello CLI 项目的最小闭环。接下来请继续阅读 docs/release-workflow.md 获取完整发布流程。