Compare commits

..

3 Commits

Author SHA1 Message Date
AI Engineer
08d2a9f2a3 feat(id): 具名化 JS 导出并动态包裹错误(by AI) 2026-06-21 10:13:28 +08:00
AI Engineer
5590037abe chore: align dependencies to v1.5.3 (by AI) 2026-06-11 20:29:20 +08:00
AI Engineer
3c1093ae57 chore: align infrastructure to v1.5.3 (by AI) 2026-06-11 18:57:44 +08:00
3 changed files with 32 additions and 19 deletions

View File

@ -1,5 +1,16 @@
# Changelog: @go/id # Changelog: @go/id
## v1.5.4 (2026-06-21)
- **重构与错误堆栈支持**:
- 重构 `js_export.go`,将 `Make` 匿名包装闭包改为包级具名函数 `jsMake`
- 升级 `encoding` 依赖至 v1.5.4`jsmod` 依赖至 v1.5.3`rand` 依赖至 v1.5.3`cast` 依赖至 v1.5.3。
## v1.5.3 (2026-06-11)
- **版本对齐**: 基础设施全局对齐 v1.5.3。
## v1.5.2 (2026-06-09)
- **版本对齐**: 基础设施全局对齐 v1.5.2。
## v1.5.1 (2026-06-08) ## v1.5.1 (2026-06-08)
- **JS 极简 API**: 彻底废除 JS 侧冗长难记的 `get8Bytes...` 等方法,统一收敛为极简的 `Make(size int, forDB ...string)`。充分利用了底层 JS Bridge 的零值回退特性,在不填第二个参数时也能安全优雅地工作。 - **JS 极简 API**: 彻底废除 JS 侧冗长难记的 `get8Bytes...` 等方法,统一收敛为极简的 `Make(size int, forDB ...string)`。充分利用了底层 JS Bridge 的零值回退特性,在不填第二个参数时也能安全优雅地工作。

8
go.mod
View File

@ -3,9 +3,9 @@ module apigo.cc/go/id
go 1.25.0 go 1.25.0
require ( require (
apigo.cc/go/encoding v1.5.0 apigo.cc/go/encoding v1.5.4
apigo.cc/go/jsmod v1.5.0 apigo.cc/go/jsmod v1.5.3
apigo.cc/go/rand v1.5.0 apigo.cc/go/rand v1.5.3
) )
require apigo.cc/go/cast v1.5.0 // indirect require apigo.cc/go/cast v1.5.3

View File

@ -8,20 +8,22 @@ import (
func init() { func init() {
jsmod.Register("id", map[string]any{ jsmod.Register("id", map[string]any{
"Make": func(size int, forDB *string) string { "Make": jsMake,
dbType := ""
if forDB != nil {
dbType = strings.ToLower(*forDB)
}
switch dbType {
case "mysql":
return DefaultIDMaker.GetForMysql(size)
case "postgres", "pg", "pgsql":
return DefaultIDMaker.GetForPostgreSQL(size)
default:
return DefaultIDMaker.Get(size)
}
},
}) })
} }
func jsMake(size int, forDB *string) string {
dbType := ""
if forDB != nil {
dbType = strings.ToLower(*forDB)
}
switch dbType {
case "mysql":
return DefaultIDMaker.GetForMysql(size)
case "postgres", "pg", "pgsql":
return DefaultIDMaker.GetForPostgreSQL(size)
default:
return DefaultIDMaker.Get(size)
}
}