| | |
🛠 功能簡介
此工具可將 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[];
}