Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ jobs:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with不用吧?一直用最新的就行?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explicit version pinning is preferred here to ensure CI stability. Using actions/setup-go@v5 without version specification would automatically use the latest Go version available in the runner, which could lead to unexpected breakages when Go 1.27+ is released. Keeping with: go-version: '1.24' ensures consistent builds across time.

go-version: '1.24'

- name: Build
run: go build -v ./...
Expand Down
88 changes: 88 additions & 0 deletions docs/superpowers/specs/2026-03-10-caskin-modernization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# caskin 现代化迭代设计文档

**日期:** 2026-03-10
**目标:** 分阶段对 caskin 进行现代化维护和文档建设,保持向后兼容,不让存量用户用不了

---

## 背景

caskin 是一个 Go 的多域 RBAC 权限管理库,基于 casbin 开发。最后一次提交是 2023 年 5 月,处于维护停滞状态。依赖版本较旧(Go 1.20),文档不完善,示例缺乏。

## 目标

1. **现代化维护** — Go 版本 + 依赖升级,使用新语法,分阶段进行避免存量用户不兼容
2. **文档建设** — 使用者文档(快速上手、API 说明)+ 贡献者文档(架构设计)

## 原则

- 分阶段渐进,**每个 Phase 切换前等用户确认**
- 每次有意义的改动单独 PR + commit,保持可回滚
- Breaking change 单独 PR,附 CHANGELOG 说明
- 语法现代化和依赖升级分开 PR

---

## Phase 1:地基(2-3 周)

**目标:让项目跑起来、看得懂**

### 任务清单

- [ ] 升级 Go 到最新版(1.24)
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.26

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sticking with Go 1.24 is intentional. While Go 1.26 is the latest, it was just released in Feb 2026 and may have stability issues. Go 1.24 (released Feb 2025) is mature enough for all modernization goals (any, range over integers, slices/maps stdlib, generics). For a library project like caskin, using a version that's been battle-tested for a year provides better stability guarantees for downstream users. We can revisit 1.26 in Phase 2 or 3 once it's proven stable.

- [ ] 依赖升级(只升无破坏性变更的小版本/patch)
- [ ] 跑通所有现有测试,修复失败的
- [ ] 使用新 Go 语法重构:
- `interface{}` → `any`
- `range` over integers(Go 1.22)
- `slices` / `maps` 标准库替换手写循环
- `min()` / `max()` 内置函数
- 适当引入泛型简化重复代码
- [ ] 完善 README:补充真实可运行的 Quick Start 示例
- [ ] 补充 godoc 注释(核心 API)

**卡点:完成后汇报,等用户确认进入 Phase 2**

---

## Phase 2:文档建设(2-3 周)

**目标:让新用户能快速上手,让贡献者能参与**

### 任务清单

- [ ] 重写 Getting Started(step-by-step,有完整可运行代码)
- [ ] API 文档:每个方法说明参数、返回值、使用场景
- [ ] 增加常见使用场景示例:
- 多域管理
- 角色继承
- 权限检查
- 前端/后端权限分离
- [ ] 架构说明文档(给贡献者看)
- [ ] CONTRIBUTING.md

**卡点:完成后汇报,等用户确认进入 Phase 3**

---

## Phase 3:现代化深化(3-4 周)

**目标:主要依赖全面更新,代码质量提升**

### 任务清单

- [ ] 升级 casbin v2 到最新版(评估破坏性影响,分 PR)
- [ ] 升级 gorm、redis-watcher 等主要依赖
- [ ] 提升测试覆盖率(目标 80%+)
- [ ] 每个 breaking change 单独 PR + CHANGELOG

**卡点:完成后汇报,评估是否有 Phase 4**

---

## 推进节奏

- 每 **2-3 天** 自动推进一个小任务
- 完成有意义节点后在对话里发进度报告
- Phase 切换必须等用户确认
- 所有改动都 commit,保持可回滚
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/awatercolorpen/caskin

go 1.20
go 1.24

require (
github.com/BurntSushi/toml v1.3.0
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go
github.com/ahmetb/go-linq/v3 v3.2.0 h1:BEuMfp+b59io8g5wYzNoFe9pWPalRklhlhbiU3hYZDE=
github.com/ahmetb/go-linq/v3 v3.2.0/go.mod h1:haQ3JfOeWK8HpVxMtHHEMPVgBKiYyQ+f1/kLZh/cj9U=
github.com/bsm/ginkgo/v2 v2.7.0 h1:ItPMPH90RbmZJt5GtkcNvIRuGEdwlBItdNVoyzaNQao=
github.com/bsm/ginkgo/v2 v2.7.0/go.mod h1:AiKlXPm7ItEHNc/2+OkrNG4E0ITzojb9/xWzvQ9XZ9w=
github.com/bsm/gomega v1.26.0 h1:LhQm+AFcgV2M0WyKroMASzAzCAJVpAxQXv4SaI9a69Y=
github.com/bsm/gomega v1.26.0/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
github.com/casbin/casbin/v2 v2.69.0 h1:hF9iUqqVJNqaG9U3SEmVRDe1eRmLUZZjO2MMGd2Pcuk=
github.com/casbin/casbin/v2 v2.69.0/go.mod h1:vByNa/Fchek0KZUgG5wEsl7iFsiviAYKRtgrQfcJqHg=
github.com/casbin/gorm-adapter/v3 v3.17.0 h1:nEUsNwhwWoZ9D3UY3tFKYHuN+Oxa3z2Ubx0gRB4AkkU=
Expand Down Expand Up @@ -46,6 +48,7 @@ github.com/golang-sql/sqlexp v0.1.0/go.mod h1:J4ad9Vo8ZCWQ2GMrC4UCQy1JpCbwU9m3EO
github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc=
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbuBVKCudVG457BR2GZFIz3uw3hQ=
github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
Expand All @@ -71,6 +74,7 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8=
github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI=
Expand Down
Loading