gotypegen

module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2026 License: MIT

README

gotypegen

Generate TypeScript, Python, and JSON Schema types from Go source code.

Originally based on tygo by Guido Zuidhof (MIT). Extended with Python TypedDict/Enum output, JSON Schema output, and dependency tracing.

Install

go install github.com/inference-sh/gotypegen/cmd/gotypegen@latest

Usage

gotypegen [--format=typescript,jsonschema,python] [config.yaml]
Config
packages:
  - path: "your/go/package"
    output_path: "gen/types.ts"
    type_mappings:
      time.Time: "string /* RFC3339 */"
      uuid.UUID: "string /* uuid */"
Formats
  • typescript (default) — TypeScript interfaces and const exports
  • python — Python TypedDict classes and StrEnum/IntEnum
  • jsonschema — JSON Schema 2020-12 definitions
Dependency Tracing

Only emit types reachable from specific entry files:

packages:
  - path: "your/go/package"
    output_path: "gen/sdk.ts"
    mode: "trace"
    entry_files:
      - api.go
Directives

Use //gotypegen:emit to inject raw output:

//gotypegen:emit export type CustomType = string | number;
var _ = ""

License

MIT — see LICENSE and THIRD_PARTY.

Directories

Path Synopsis
cmd
gotypegen command
gotypegen generates TypeScript, JSON Schema, and Python types from Go source code.
gotypegen generates TypeScript, JSON Schema, and Python types from Go source code.
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL