3个稳定版本
1.0.5 | 2021年7月6日 |
---|---|
1.0.1 | 2021年6月21日 |
1.0.0 | 2021年6月20日 |
#26 in #golang
39KB
1K SLoC
JS_TYPIFY_GOSTRUCT
一个将Golang结构体转换为支持的语言类型对象或接口的Rust工具。
支持的语言/类型系统。
- flow
- typescript
如何使用
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(())
}
运行示例
示例文件夹包含各种库的使用示例。
要运行特定示例,请执行以下命令
eg
cargo run --example flow
cargo run --example typescript
待办事项
- 重新引入测试并修复错误。
- 为库添加文档。
- 引入对其他语言的解释器支持,例如,gostruct -> rust struct...
- 为此库创建一个WASM包装器,以便可以在Web上原生使用。