From 7c79333926ecf9fdce1d6c6f0ff72b69af78e556 Mon Sep 17 00:00:00 2001 From: AI Engineer Date: Mon, 4 May 2026 09:57:17 +0800 Subject: [PATCH] =?UTF-8?q?fix(convert):=20=E4=BF=AE=E5=A4=8D=E7=94=B1?= =?UTF-8?q?=E4=BA=8E=20cast=20=E5=BA=93=20API=20=E5=8F=98=E6=9B=B4?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=E7=BC=96=E8=AF=91=E9=94=99=E8=AF=AF?= =?UTF-8?q?=20(by=20AI)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 5 +++++ convert.go | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d4008e..dee1207 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog: @go/convert +## [v1.0.5] - 2026-05-04 + +### Fixed +- **兼容性修复**:修复了由于 `cast` 库 API 变更导致的 `MustJSONBytes` 未定义错误,更新为 `MustToJSONBytes`。 + ## [v1.0.4] - 2026-04-30 ### Changed diff --git a/convert.go b/convert.go index 9e0e9ba..1e397b4 100644 --- a/convert.go +++ b/convert.go @@ -66,7 +66,7 @@ func performConversion(source, destination any) *reflect.Value { if realDestination.CanAddr() { address := realDestination.Addr().Interface() if unmarshaler, isJSONUnmarshaler := address.(json.Unmarshaler); isJSONUnmarshaler { - _ = unmarshaler.UnmarshalJSON(cast.MustJSONBytes(realSource.Interface())) + _ = unmarshaler.UnmarshalJSON(cast.MustToJSONBytes(realSource.Interface())) return nil } if unmarshaler, isYAMLUnmarshaler := address.(yaml.Unmarshaler); isYAMLUnmarshaler { @@ -109,7 +109,7 @@ func performConversion(source, destination any) *reflect.Value { case reflect.Slice: if destinationType.Elem().Kind() == reflect.Uint8 { - applyValue(realDestination, reflect.ValueOf(cast.MustJSONBytes(realSource.Interface())), &allocatedValue) + applyValue(realDestination, reflect.ValueOf(cast.MustToJSONBytes(realSource.Interface())), &allocatedValue) } else { normalizedSource := realSource if sourceType.Kind() == reflect.String {