docs(comments): 注释中文化 · internal/runtime/memory(31 文件,纯替换)
- 只翻注释/文档字符串:820 增 / 820 删 严格 1:1;剥掉整行注释与行尾注释尾巴后, 逐文件与 HEAD 比对「代码部分差异 = 0」;裁决/design 编号计数逐项与 HEAD 一致 - 保留可执行 SQL 样例、SQLite 报错原文、pgvector/HNSW/ANN/BLOB 等技术词原文 - 复核:go build 绿 + memory/projectindex/vector 三包测试绿;gofmt 仅剩 2 个既有未格式化文件(改动前即如此,未顺手修)
This commit is contained in:
1 parent
eb1828ee7a
commit
61cf80d5ee
31 files changed
+820
-820
No files matched your search
@@ -11,10 +11,10 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Project is a project index entry (design §3): the project marker that links
|
||||
// its chapters, together with the project's description. It is layer 1 (index
|
||||
// entry) and layer 2 (description) of the hierarchy. The zero value is not a
|
||||
// valid project: ID and Title are required.
|
||||
// Project 是一个项目索引条目(design §3):链接其
|
||||
// 各章节的项目标示,连同项目描述。它是层级的第 1 层(索引
|
||||
// 条目)与第 2 层(描述)。零值不是
|
||||
// 合法项目:ID 与 Title 必填。
|
||||
type Project struct {
|
||||
ID string
|
||||
Title string
|
||||
@@ -23,10 +23,10 @@ type Project struct {
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
// PutProject upserts p by id. On an existing id it updates title, desc, and
|
||||
// updated_at while preserving the original created_at; on a new id it assigns
|
||||
// missing timestamps and inserts. A blank id or title returns ErrMissingProject
|
||||
// or ErrMissingTitle.
|
||||
// PutProject 按 id upsert p。id 已存在时更新 title、desc 与
|
||||
// updated_at,并保留原始的 created_at;id 为新值时
|
||||
// 补齐缺失时间戳并插入。id 或 title 为空返回 ErrMissingProject
|
||||
// 或 ErrMissingTitle。
|
||||
func (s *Store) PutProject(ctx context.Context, p Project) error {
|
||||
if strings.TrimSpace(p.ID) == "" {
|
||||
return ErrMissingProject
|
||||
@@ -55,8 +55,8 @@ func (s *Store) PutProject(ctx context.Context, p Project) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetProject returns the project with the given id. It returns ErrProjectNotFound
|
||||
// when the id is blank or does not exist.
|
||||
// GetProject 返回给定 id 的项目。id 为空或
|
||||
// 不存在时返回 ErrProjectNotFound。
|
||||
func (s *Store) GetProject(ctx context.Context, id string) (*Project, error) {
|
||||
if strings.TrimSpace(id) == "" {
|
||||
return nil, ErrProjectNotFound
|
||||
@@ -73,10 +73,10 @@ func (s *Store) GetProject(ctx context.Context, id string) (*Project, error) {
|
||||
return p, nil
|
||||
}
|
||||
|
||||
// DeleteProject removes the project by id and, as a cascade, every chapter that
|
||||
// references it. It returns ErrProjectNotFound when the id is blank or no
|
||||
// project row was removed. The project removal and the chapter removal happen in
|
||||
// one transaction so a failure never leaves an orphaned project or chapter.
|
||||
// DeleteProject 按 id 删除项目,并级联删除引用它的每个
|
||||
// 章节。id 为空、或没有删除任何
|
||||
// 项目行时返回 ErrProjectNotFound。删项目与删章节发生在
|
||||
// 同一事务内,因此失败绝不会留下孤儿项目或章节。
|
||||
func (s *Store) DeleteProject(ctx context.Context, id string) error {
|
||||
if strings.TrimSpace(id) == "" {
|
||||
return ErrProjectNotFound
|
||||
@@ -113,7 +113,7 @@ func (s *Store) DeleteProject(ctx context.Context, id string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// scanProject reads one project row.
|
||||
// scanProject 读取一行 project。
|
||||
func scanProject(sc rowScanner) (*Project, error) {
|
||||
var (
|
||||
p Project
|
||||
@@ -132,9 +132,9 @@ func scanProject(sc rowScanner) (*Project, error) {
|
||||
return &p, nil
|
||||
}
|
||||
|
||||
// newID returns a 128-bit cryptographically random id, hex-encoded. It avoids a
|
||||
// UUID dependency so the package stays self-contained. rand.Read fails only if
|
||||
// the platform entropy source is broken, so the error is propagated.
|
||||
// newID 返回一个 128 位密码学随机 id,十六进制编码。它避开
|
||||
// UUID 依赖,使本包保持自包含。rand.Read 只在
|
||||
// 平台熵源损坏时失败,因此错误向上传播。
|
||||
func newID() (string, error) {
|
||||
b := make([]byte, 16)
|
||||
if _, err := rand.Read(b); err != nil {
|
||||
|
||||
Reference in new issue
Block a user