zserio code generation in Go.
go-zserio is still in active development, and not completely stable yet. Until
the first stable release all versions will have a major version number of 0.
The minor version number will be updated for (API) breaking changes.
First you need to install the go-zserio command:
go install github.com/woven-planet/go-zserio/cmd/go-zserio@latestWith this command you can generate the Go interface files to read/write zserio:
go-zserio generate <zserio_directory> --rootpackage <root_package> --out <output_directory>This command compiles the zserio files, and generates Go files to read and write
zserio encoded data. zserio_directory is the directory where the zserio
definitions are stored. Supported file extensions are .zs and .zserio.
rootpackage specifies the root package name of the generated Go files.
output_directory specifies the path where the Go files will be generated.
When reading arrays, strings and bytes (blobs) zserio defaults to not allocate more memory than a configurable maximum. This is a safety measure to prevent allocating all memory and entering an out-of-memory state if the input has invalid sizes data. This could happen when dealing with untrusted or corrupted input. This behavior can be controlled using environment variables.
| Environment variable | Default | Description |
|---|---|---|
ZSERIO_MAX_INITIAL_ARRAY_SIZE |
1000 | Maximum initial capacity for arrays |
ZSERIO_MAX_INITIAL_BLOB_SIZE |
102400 (100kB) | Maximum initial capacity of bytes and strings |
Setting an environment variable to 0 removes the maximum, which can result in
a small performance gain. This should only be done when the input is trusted.
- Implicit length arrays are deprecated, and are not supported.
- The ternary operator only works when used in functions.
- Cyclic imports, while not recommended, are supported by zserio, but not supported by go-zserio.
- Offsets and indexed offsets are not implemented yet.
- Constraints are not implemented yet.
- The
bazel run //internal/parser:updatecommand to rerun theantlrparser does not work on Windows. See #128 for more details.