Expand description
§Go Away
Go Away is a small library for generating go types & marshalling code from Rust type definitions. It’s intended for use when you have existing rust code that is using serde for JSON serialization and you want to allow go services or clients to interact with that code.
It may be expanded to other languages at some point but it’s mostly been built to service a very specific need and might never evolve past that.
Use is fairly simple:
use go_away::{TypeMetadata, TypeRegistry};
// First, derive TypeMetadata on some types:
#[derive(TypeMetadata)]
struct MyType {
my_field: String
}
// Then you can register this type inside a `TypeRegistry`
let mut registry = TypeRegistry::new();
MyType::metadata(&mut registry);
// And get some go code to write out to a file:
let go_code = go_away::registry_to_output::<go_away::GoType>(®istry);
Note that the output go code does not contain any package definitions or required imports.
It’s expected that any code that calls go-away
will add this for itself.
Modules§
- types
- Defines the type model for go-away - a set of structs that describe types and can be used to generate copies of them in other languages.
Structs§
- TypeId
- A type identifier - used to deduplicate types in the output
- Type
Registry - A registry of type details.
Enums§
- GoType
- An enum representing the possible top-level types in Golang
- Type
Script Type - An enum representing the possible top-level types in TypeScript
Traits§
- Type
Alias - A trait for types that can be registered as aliases.
- Type
Metadata - Exposes metadata about a type that can be used to generate other versions of that type in other languages.
Functions§
- registry_
to_ output - Generates code for all the types in the TypeRegistry
Derive Macros§
- Type
Metadata - Derives TypeMetadata for a given struct.