This is an automated email from the ASF dual-hosted git repository. chaokunyang pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/fory-site.git
commit 2510a252d8e200d05053e75032a426ed101b9712 Author: chaokunyang <[email protected]> AuthorDate: Fri May 1 03:16:43 2026 +0000 🔄 synced local 'docs/guide/' with remote 'docs/guide/' --- docs/guide/go/struct-tags.md | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/docs/guide/go/struct-tags.md b/docs/guide/go/struct-tags.md index 742aa9df1f..b973769eb2 100644 --- a/docs/guide/go/struct-tags.md +++ b/docs/guide/go/struct-tags.md @@ -152,17 +152,33 @@ type Metrics struct { - `fixed`: Best for values that use full range (e.g., timestamps, hashes) - `tagged`: When type information needs to be preserved -**Shorthand for int32/uint32**: +### Type Overrides -Use `compress` as a convenience tag for int32/uint32 fields: +Use `type=` to override inferred carrier semantics or nested value encoding: ```go -type Data struct { - SmallValue int32 `fory:"compress"` // Same as encoding=varint (default) - FixedValue uint32 `fory:"compress=false"` // Same as encoding=fixed +type Foo struct { + // Force general LIST protocol instead of inferred packed INT32_ARRAY + Values []int32 `fory:"type=list"` + + // Override inner integer encoding for a general list + FixedValues []int32 `fory:"type=list(element=int32(encoding=fixed))"` + + // Override nested map/list integer encoding + Nested map[string][]*uint64 `fory:"type=map(value=list(element=uint64(encoding=tagged)))"` + + // Preserve the inferred packed inner carrier and only override descendants + Packed map[string][]int32 `fory:"type=map(value=_(element=int32(encoding=fixed)))"` } ``` +**Notes**: + +- `list(...)`, `set(...)`, and `map(...)` are explicit container overrides +- `_` keeps the inferred Go branch at that position and only overrides nested descendants +- There is no public `array(...)` tag. Packed primitive arrays are inferred from Go `[]T` / `[N]T` when the final element spec is packable +- Explicit `type=list(...)` always stays general LIST protocol and never collapses into a packed primitive array + ## Combining Tags Multiple tags can be combined using comma separator: @@ -171,7 +187,7 @@ Multiple tags can be combined using comma separator: type Document struct { ID int64 `fory:"id=0,encoding=fixed"` Content string `fory:"id=1"` - Author *User `fory:"id=2,ref"` + Author *User `fory:"id=2,nullable=false,ref"` } ``` --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
