typify_gostruct 1.0.5

A rust tool meant to convert a golang struct to a type object of available languages.
Documentation
  • Coverage
  • 50%
    3 out of 6 items documented2 out of 3 items with examples
  • Size
  • Source code size: 39.13 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 456.1 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • tevs-rust-land/typify_gostruct
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Tevinthuku

Gitpod ready-to-code

JS_TYPIFY_GOSTRUCT

A rust tool meant to convert a golang struct to a type object/interface or the supported languages.

Supported languages / typesystems.

  1. flow
  2. typescript

How to use

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(())
}

Running the examples

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

  • Re-introduce tests & fix bugs.
  • Add documentation for the library.
  • Introduce interpreter support for other languages,eg, gostruct -> rust struct....
  • Make a WASM wrapper for this library so that it can be used natively on the web.