GoDMT

Build Go Report Card PkgGoDev Maintainability codecov License

GoDMT, the one and only Go Data Model Translator. The goal of this project is to provide a tool that can parse Go files that include var, const, map, struct and type into an abstract syntax tree, aka AST.

That AST will then be transformed into data models for several programming languages. Currently GoDMT can perform translations to:

  • TypeScript
  • Swift (using Decodable structs)
  • JSON
  • PHP

Some small adjustments may need to be made to integrate the output into a project, but this should already save you a lot of time and hassle, and will help you stay in sync with the Go version of your data models, in other languages. Comments will be carried over
😉
.

Currently, the tested operating systems are:

  • Linux (amd64)
  • FreeBSD (amd64)
  • macOS (amd64)
  • Windows (amd64)

Feel free to expand this list if you have successfully used the tool in other environments. You will find pre-compiled binaries of the tool in the releases page.

Talk is cheap, show code

Feel free to browse some examples that I am happy to provide here:

Usage

See the CLI Usage wiki page for more details on using the tool.

See the Tags and Name Conversion section to understand more about how entities get parsed and converted to other languages.

Building

To build this application as a binary simply navigate to cmd/godmt and run go build.

GitHub

https://github.com/averageflow/godmt