chore(cast): 移除 jsontag 依赖

This commit is contained in:
AI Engineer 2026-05-09 16:30:01 +08:00
parent dd63c8eae8
commit 8b5ff08d62
5 changed files with 13 additions and 8 deletions

View File

@ -1,5 +1,9 @@
# CHANGELOG # CHANGELOG
## [v1.2.9] - 2026-05-09
### Changed
- **移除第三方依赖**: 移除了对 `jsontag` 模块的依赖,统一使用标准库及自有基础设施对齐,增强了模块的独立性与长期稳定性。
## [v1.2.8] - 2026-05-05 ## [v1.2.8] - 2026-05-05
### Fixed ### Fixed
- **JSON 解码器深度增强**: 修复了 `cast.UnmarshalJSON` 在反序列化到 `interface{}` 类型字段时会跳过对象和数组的重大缺陷。 - **JSON 解码器深度增强**: 修复了 `cast.UnmarshalJSON` 在反序列化到 `interface{}` 类型字段时会跳过对象和数组的重大缺陷。

View File

@ -66,8 +66,8 @@ func BenchmarkString(b *testing.B) {
func BenchmarkJSON(b *testing.B) { func BenchmarkJSON(b *testing.B) {
type User struct { type User struct {
ID int `json:"id"` ID int
Name string `json:"name"` Name string
} }
u := User{ID: 1, Name: "Benchmark User"} u := User{ID: 1, Name: "Benchmark User"}
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
@ -140,8 +140,8 @@ func BenchmarkString_FastPath(b *testing.B) {
// 4. 测试 ToJSON 性能 (对比自定义逻辑与标准库) // 4. 测试 ToJSON 性能 (对比自定义逻辑与标准库)
func BenchmarkToJSON_SimpleStruct(b *testing.B) { func BenchmarkToJSON_SimpleStruct(b *testing.B) {
type User struct { type User struct {
ID int `json:"id"` ID int
Name string `json:"name"` Name string
} }
u := User{ID: 1, Name: "Benchmark User"} u := User{ID: 1, Name: "Benchmark User"}
b.ResetTimer() b.ResetTimer()

View File

@ -55,7 +55,7 @@ func TestJSONToStruct(t *testing.T) {
func TestSpecialJSON(t *testing.T) { func TestSpecialJSON(t *testing.T) {
// 关键测试:特殊 HTML 字符序列化不应被转义 // 关键测试:特殊 HTML 字符序列化不应被转义
type Content struct { type Content struct {
Text string `json:"text"` Text string
} }
c := Content{Text: "<a> & <b>"} c := Content{Text: "<a> & <b>"}

View File

@ -46,7 +46,7 @@ func TestToSlice(t *testing.T) {
func TestJSON(t *testing.T) { func TestJSON(t *testing.T) {
type Config struct { type Config struct {
Port int `json:"port"` Port int
} }
data := `{"port": 8080}` data := `{"port": 8080}`

View File

@ -2,6 +2,7 @@ package cast_test
import ( import (
"testing" "testing"
"apigo.cc/go/cast" "apigo.cc/go/cast"
) )
@ -28,7 +29,7 @@ func TestTo(t *testing.T) {
// JSON Auto conversion (Struct to String) // JSON Auto conversion (Struct to String)
type User struct { type User struct {
Name string `json:"name"` Name string
} }
u := User{Name: "Alice"} u := User{Name: "Alice"}
js := cast.To[string](u) js := cast.To[string](u)