Tool that can parse Go files into an abstract syntax tree and translate it to several programming languages.

Overview

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.

Comments
  • Fix: godmt may break because of invalid path on windows.

    Fix: godmt may break because of invalid path on windows.

    Closes #12

    The code successfully executed on windows with expected results, without modifying the code. However, transforming the directory paths to a unified format may save us in some cases.

    opened by akshaybharambe14 1
  • Configure WhiteSource Bolt for GitHub

    Configure WhiteSource Bolt for GitHub

    Welcome to WhiteSource Bolt for GitHub! This is an onboarding PR to help you understand and configure settings before WhiteSource starts scanning your repository for security vulnerabilities.

    :vertical_traffic_light: WhiteSource Bolt for GitHub will start scanning your repository only once you merge this Pull Request. To disable WhiteSource Bolt for GitHub, simply close this Pull Request.


    What to Expect

    This PR contains a '.whitesource' configuration file which can be customized to your needs. If no changes were applied to this file, WhiteSource Bolt for GitHub will use the default configuration.

    Before merging this PR, Make sure the Issues tab is enabled. Once you merge this PR, WhiteSource Bolt for GitHub will scan your repository and create a GitHub Issue for every vulnerability detected in your repository.

    If you do not want a GitHub Issue to be created for each detected vulnerability, you can edit the '.whitesource' file and set the 'minSeverityLevel' parameter to 'NONE'.


    :question: Got questions? Check out WhiteSource Bolt for GitHub docs. If you need any further assistance then you can also request help here.

    opened by mend-bolt-for-github[bot] 1
  • Let users specify the output directory

    Let users specify the output directory

    Is your feature request related to a problem? Please describe.

    The users may want to put the generated files to a desired directory.

    Describe the solution you'd like

    A flag, preferably `-o=path/to/output/dir", can help.

    Describe alternatives you've considered N/A

    Additional context N/A

    enhancement good first issue 
    opened by akshaybharambe14 1
  • When the json label is not given a syntax error occurs

    When the json label is not given a syntax error occurs

    type Example struct {
      ID string `uri:"id"`
    }
    

    for example this will generate:

    export interface Example {
    	"`uri:"id"`": string;
    }
    

    and should generate:

    export interface Example {
    	ID: string;
    }
    

    A the name should be used as a fallback for a json label.


    Here is a happy flow with json label:

    type Example struct {
      ID string `json:"id"`
    }
    
    export interface Example {
    	id: string;
    }
    
    bug good first issue 
    opened by lil5 1
  • [ImgBot] Optimize images

    [ImgBot] Optimize images

    opened by imgbot[bot] 1
  • Support iota enums

    Support iota enums

    In Go you can use the special iota expression for auto incrementing values of an enum. This should be supported in GoDMT by translating those enums to the correct value (based on position)

    enhancement 
    opened by averageflow 0
  • Slice of imported entity is not correctly translated.

    Slice of imported entity is not correctly translated.

    Describe the bug When a struct has a field that is an imported entity, and in the form of a slice of those entities, the translation is not correct.

    Expected behavior

    Media       []ProductCategoryImage `json:"media"`
    

    would produce:

    media: ProductCategoryImage[];
    

    Actual result

    Media       []ProductCategoryImage `json:"media"`
    

    produces:

    media: ProductCategoryImage | null[];
    

    OS (please complete the following information):

    • macOS
    • Big Sur
    bug 
    opened by averageflow 0
  • Reduce usage of package reflect

    Reduce usage of package reflect

    There is actually no valid reason (apart from laziness) to use the reflect package for GoDMT. Reducing its usage as much as possible will bring more performance, type safety, cleaner code and more handling of edge cases.

    enhancement help wanted good first issue 
    opened by averageflow 0
  • PHP embedded structs support

    PHP embedded structs support

    Some creativity and investigation will be required for this. My idea is to create a second class perhaps and an instance property of the parent class whose type is the 2nd class.

    enhancement good first issue 
    opened by averageflow 0
Releases(v1.4.4)
Owner
Josep Jesus Bigorra Algaba
Software Engineer, Backend/Middleware
Josep Jesus Bigorra Algaba
Generate plantuml diagrams from go source files or directories

go-plantuml go-plantuml generates plantuml diagrams from go source files or directories. Installation go get -u github.com/bykof/go-plantuml Please co

Michael Bykovski 283 Dec 5, 2022
gosivy - Another visualization tool for Go process metrics

gosivy Another visualization tool for Go process metrics. Gosivy tracks Go process's metrics and plot their evolution over time right into your termin

Ryo Nakao 449 Nov 27, 2022
Tool to visualize the graph of embedded structs in Go projects

Visualize a hierarchy of embedded Go structs This tool scans a directory of Go source code files to create a visualization of struct embedding in the

David Schlachter 215 Nov 27, 2022
Interactive dependency graph visualization tool for golang

Interactive dependency graph visualization tool for golang using the awesome cytoscape graph visualizer.

Armin Becher 6 Sep 1, 2022
An SVG-based tool to visualize public transport journeys retrieved from a HAFAS system

Time-Space Train Planner An SVG-based tool to visualize public transport journeys retrieved from a HAFAS system, in order to see all possible connecti

Traines 39 Nov 5, 2022
Helm : a tool for managing Charts

Helm is a tool for managing Charts. Charts are packages of pre-configured Kubernetes resources.

邓杰 0 Aug 25, 2022
A repository for plotting and visualizing data

gonum/plot is the new, official fork of code.google.com/p/plotinum. It provides an API for building and drawing plots in Go

null 2.3k Dec 2, 2022
Callgraph analysis and visualization for Go

Gocyto A Go SSA callgraph builder and visualizer, by @protolambda. Features: output to generic Cytoscape JSON format. (list of nodes, list of edges) o

Diederik Loerakker 137 Nov 3, 2022
A repository for plotting and visualizing data

Gonum Plot gonum/plot is the new, official fork of code.google.com/p/plotinum. It provides an API for building and drawing plots in Go. Note that this

null 19.1k Jun 3, 2021
Interactive Terraform visualization. State and configuration explorer.

Rover - Terraform Visualizer Rover is a Terraform visualizer. In order to do this, Rover: generates a plan file and parses the configuration in the ro

Tu Nguyen 2.3k Dec 4, 2022
Ltree Visualizer - A golang library to visualize postgres ltree type data using DOT language and Graphviz

Ltree Visualizer A golang library to visualize postgres ltree type data using DOT language and Graphviz What is Ltree? Ltree is a data type which is u

Vasubabu Jinagam 8 Jun 12, 2022
termdbms: A TUI for viewing and editing databases, written in Go

termdbms: A TUI for viewing and editing databases, written in Go Database Support SQLite made with modernc.org/sqlite, charmbracelet/bubbletea, and c

Matt Farstad 1.2k Nov 26, 2022
Using NFP (Number Format Parser) you can get an Abstract Syntax Tree (AST) from Excel number format expression

NFP (Number Format Parser) Using NFP (Number Format Parser) you can get an Abstract Syntax Tree (AST) from Excel number format expression. Installatio

fossabot 0 Feb 4, 2022
Translate your Go program into multiple languages with similar fmt.Sprintf format syntax.

Loafer-i18n Loafer-i18n is a Go package and a command that helps you translate Go programs into multiple languages. Supports pluralized strings with =

EasyGram 0 Dec 22, 2021
go-i18n is a Go package and a command that helps you translate Go programs into multiple languages.

go-i18n is a Go package and a command that helps you translate Go programs into multiple languages.

Nick Snyder 2.2k Dec 1, 2022
Translate your Go program into multiple languages.

go-i18n go-i18n is a Go package and a command that helps you translate Go programs into multiple languages. Supports pluralized strings for all 200+ l

Nick Snyder 2.2k Dec 1, 2022
libraries for various programming languages that make it easy to generate per-process trace files that can be loaded into chrome://tracing

chrometracing: chrome://tracing trace_event files The chrometracing directory contains libraries for various programming languages that make it easy t

Google 23 Oct 6, 2022
Split multiple Kubernetes files into smaller files with ease. Split multi-YAML files into individual files.

Split multiple Kubernetes files into smaller files with ease. Split multi-YAML files into individual files.

Patrick D'appollonio 199 Nov 28, 2022
Split multiple Kubernetes files into smaller files with ease. Split multi-YAML files into individual files.

kubectl-slice: split Kubernetes YAMLs into files kubectl-slice is a neat tool that allows you to split a single multi-YAML Kubernetes manifest into mu

Patrick D'appollonio 200 Dec 2, 2022
Show Languages In Code. A fast and lightweight CLI to generate stats on the languages inside your project

slic Show Languages In Code. Usage Run it with an -h flag to list all commands. -d flag can be used to specify the directory of search -i flag can be

Saurav Pal 3 Dec 25, 2021