GO在线工具集
首页
搜索
致Boss

Go Struct 转 TypeScript 工具
33  |   |   |  1

🛠 功能简介

该工具可将 Go 语言中的 struct 结构体转换为 TypeScript 类型定义(interface 或 type),支持解析常见基础类型、数组、map、嵌套结构体、json 标签等。

✅ 支持的 Go 类型

Go 类型TypeScript 类型
stringstring
int / int64number
float32 / float64number
boolboolean
[]TT[]
TT
otherstring

📝 使用示例

输入 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[];
}