| Crates.io | typify_gostruct |
| lib.rs | typify_gostruct |
| version | 1.0.5 |
| created_at | 2021-06-20 10:37:06.802849+00 |
| updated_at | 2021-07-06 18:38:17.764765+00 |
| description | A rust tool meant to convert a golang struct to a type object of available languages. |
| homepage | |
| repository | https://github.com/tevs-rust-land/typify_gostruct |
| max_upload_size | |
| id | 412382 |
| size | 39,132 |
A rust tool meant to convert a golang struct to a type object/interface or the supported languages.
use typify_gostruct::Source;
fn main() -> Result<(), Vec<String>> {
let example = r#"
type Region struct {
Country string `json:"country"`
State string `json:"state"`
}
"#;
// converts to flow
let source = Source::new(example);
let result = source.transform_to("flow")?;
println!("{}", result);
// result will be
// // @flow
//export type Region = {country : string, state : string, }
// converts to typescript
let result = source.transform_to("typescript")?;
println!("{}", result);
// result will be
//export interface Region = {country : string, state : string, }
Ok(())
}
The examples folder contains various examples of how the library works & is to be used.
To run a specific example run the following command
eg
cargo run --example flow
cargo run --example typescript
TODO