新
| | |
🛠 功能简介
该工具可将 Go 语言中的 struct
结构体转换为 TypeScript 类型定义(interface 或 type),支持解析常见基础类型、数组、map、嵌套结构体、json
标签等。
✅ 支持的 Go 类型
Go 类型 | TypeScript 类型 |
---|---|
string | string |
int / int64 | number |
float32 / float64 | number |
bool | boolean |
[]T | T[] |
T | T |
other | string |
📝 使用示例
输入 Go 结构体:
type User struct {
ID int `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
CreatedAt time.Time `json:"created_at"`
Tags []string `json:"tags"`
}
输出 TypeScript 类型:
interface User {
id: number;
name: string;
email: string;
created_at: string;
tags: string[];
}