chore(cast): 移除 jsontag 依赖
This commit is contained in:
parent
dd63c8eae8
commit
8b5ff08d62
@ -1,5 +1,9 @@
|
||||
# CHANGELOG
|
||||
|
||||
## [v1.2.9] - 2026-05-09
|
||||
### Changed
|
||||
- **移除第三方依赖**: 移除了对 `jsontag` 模块的依赖,统一使用标准库及自有基础设施对齐,增强了模块的独立性与长期稳定性。
|
||||
|
||||
## [v1.2.8] - 2026-05-05
|
||||
### Fixed
|
||||
- **JSON 解码器深度增强**: 修复了 `cast.UnmarshalJSON` 在反序列化到 `interface{}` 类型字段时会跳过对象和数组的重大缺陷。
|
||||
|
||||
@ -66,8 +66,8 @@ func BenchmarkString(b *testing.B) {
|
||||
|
||||
func BenchmarkJSON(b *testing.B) {
|
||||
type User struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
ID int
|
||||
Name string
|
||||
}
|
||||
u := User{ID: 1, Name: "Benchmark User"}
|
||||
for i := 0; i < b.N; i++ {
|
||||
@ -140,8 +140,8 @@ func BenchmarkString_FastPath(b *testing.B) {
|
||||
// 4. 测试 ToJSON 性能 (对比自定义逻辑与标准库)
|
||||
func BenchmarkToJSON_SimpleStruct(b *testing.B) {
|
||||
type User struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
ID int
|
||||
Name string
|
||||
}
|
||||
u := User{ID: 1, Name: "Benchmark User"}
|
||||
b.ResetTimer()
|
||||
|
||||
@ -55,7 +55,7 @@ func TestJSONToStruct(t *testing.T) {
|
||||
func TestSpecialJSON(t *testing.T) {
|
||||
// 关键测试:特殊 HTML 字符序列化不应被转义
|
||||
type Content struct {
|
||||
Text string `json:"text"`
|
||||
Text string
|
||||
}
|
||||
c := Content{Text: "<a> & <b>"}
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@ func TestToSlice(t *testing.T) {
|
||||
|
||||
func TestJSON(t *testing.T) {
|
||||
type Config struct {
|
||||
Port int `json:"port"`
|
||||
Port int
|
||||
}
|
||||
data := `{"port": 8080}`
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ package cast_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"apigo.cc/go/cast"
|
||||
)
|
||||
|
||||
@ -28,7 +29,7 @@ func TestTo(t *testing.T) {
|
||||
|
||||
// JSON Auto conversion (Struct to String)
|
||||
type User struct {
|
||||
Name string `json:"name"`
|
||||
Name string
|
||||
}
|
||||
u := User{Name: "Alice"}
|
||||
js := cast.To[string](u)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user