Giter VIP home page Giter VIP logo

godmt's Introduction

GoDMT

Build Go Report Card PkgGoDev Maintainability codecov Issues 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.

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 supported operating systems are all of UNIX family:

  • Linux
  • BSD
  • macOS

Talk is cheap, show code

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

Usage

go run main.go -dir={scanDirectory} -translation={language} -preserve -tree
  • scanDirectory represents a string that is the relative path of the directory whose Go files you want to scan. The scan occurs in a recursive manner, so all files from all contained folders will be scanned.
  • language represents the output mode. If the -translation flag is not specified it will default to JSON. Currently supported options are:
    • ts or typescript for TypeScript conversion
    • swift for Swift conversion
    • json for JSON conversion
    • php for PHP conversion
  • preserve is an optional boolean flag which will make the output structs preserve the original names, instead of using the (json:"tag").
  • tree is an optional boolean that when present will prevent any file operations being performed, and instead will show you the full abstract syntax tree of your files in the standard output.

Example usage:

go run main.go -dir=../../tests/data/ -translation=ts

After a successful run, the program will output a result folder in the current working directory with subfolders for respective scanned packages. Filenames will be respected and maintained, with only changes to the extension.

Building

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

godmt's People

Contributors

imgbotapp avatar teutonicjoe avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.