-
-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add pointer-string support to fromJSON & preserve interfaces
This commit enables fromJSON to accept both string and *string arguments by performing a runtime check on the provided argument. It also refactors the deref.Type function to preserve interface types, ensuring methods sets are not lost when unwrapping pointers. Changes: - fromJSON now handles `string` and `*string` distinctly, returning an error if the pointer is nil or if an unsupported type is given. - deref.Type preserves the Kind() == reflect.Interface immediately instead of unwrapping further, which prevents losing interface method sets. - Updated unit tests to confirm that interface-wrapped pointers are unwrapped correctly (e.g., reflect.String) and interface types remain interfaces. Signed-off-by: Ville Vesilehto <[email protected]>
- Loading branch information
1 parent
86798a6
commit 846b310
Showing
3 changed files
with
51 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters