Skip to content

Conversation

@chaokunyang
Copy link
Collaborator

@chaokunyang chaokunyang commented Dec 19, 2025

Why?

The existing Go serialization implementation needed to be aligned with the xlang serialization specification for proper cross-language interoperability.

What does this PR do?

  • Implements xlang serialization spec for Fory Go with full cross-language support
  • Refactors Go serialization code for better maintainability:
    • Restructures array, slice, map, struct, and primitive serializers
    • Adds RefMode support for flexible reference tracking
    • Improves buffer read/write APIs
  • Adds comprehensive xlang test infrastructure:
    • Go xlang test executable (xlang_test_main.go)
    • Java GoXlangTest and shared XlangTestBase for cross-language verification
    • Rust cross-language tests (test_cross_language.rs)
    • C++ xlang test support (xlang_test_main.cc)
  • Updates TypeDef encoding/decoding for cross-language compatibility

Related issues

#1017
#2982

Closes #3013
Closes #3014

Does this PR introduce any user-facing change?

  • Does this PR introduce any public API change?
  • Does this PR introduce any binary protocol compatibility change?

Benchmark

N/A

@chaokunyang chaokunyang force-pushed the align_go_with_java_serialization branch from 2bd346e to 26b04a6 Compare December 19, 2025 06:02
- Change Deserialize to take target parameter directly
- Change DeserializeFrom to take target parameter directly
- Remove convertSlice and convertMap functions
- Add readArrayValue for direct array deserialization
- Remove SerializeAny, DeserializeAny, DeserializeFromAny
- Keep Marshal/Unmarshal as convenience aliases
@chaokunyang chaokunyang force-pushed the align_go_with_java_serialization branch from a19780a to 11b1341 Compare December 19, 2025 08:52
The generated Read method only read the type ID with ReadVaruint32(),
but for NAMED_STRUCT types, writeTypeInfo also writes namespace and
typename metadata. This caused hash mismatch errors during deserialization
because the reader was off by the size of the metadata bytes.

Changes:
- Export ReadTypeInfo and WriteTypeInfo methods in TypeResolver
- Update codegen to call ReadTypeInfo instead of just ReadVaruint32
- Remove debug output from pointer.go
- Regenerate test serializers with the fix
- Fix C++ code style in type_resolver.h and xlang_test_main.cc
- Fix Java code style in XlangTestBase.java
- Fix GoXlangTest to work on Windows by adding .exe extension
  and using proper command prefix for Windows platform
- Add Go Xlang Test CI job similar to C++ Xlang Test
- Skip GoXlangTest by default unless FORY_GO_JAVA_CI=1 is set
- This prevents Go xlang tests from running in regular Java CI
@chaokunyang chaokunyang force-pushed the align_go_with_java_serialization branch from 3abab4a to 77800ec Compare December 19, 2025 09:46
@chaokunyang chaokunyang force-pushed the align_go_with_java_serialization branch from 9284067 to 74d0b3c Compare December 19, 2025 09:50
@chaokunyang chaokunyang merged commit ccf66d4 into apache:main Dec 19, 2025
55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Go] Support polymorphic map key/values serialization [Go] Support polymorphic slice elements serialization

3 participants