Giter Site home page Giter Site logo

goastgen's Introduction

AST generator

This utility generates Abstract Syntax Tree (AST) for .go files in JSON format.

If you pass the root folder of the go project, it will iterate through all .go files from project directory and generate ast in JSON format for each .go file.

Usage

Building

Run below command from within root folder of the cloned repository.

 go build -o build/goastgen

This will generate native binary for your local machine inside build folder

Getting Help

build/goastgen -help

Usage:
	goastgen [falgs] <source location>

Flags:
  -help
    	print the usage
  -out string
    	Out put location of ast (default ".ast")
  -version
    	print the version

Example

Single file

  1. Generate AST with single .go file path without passing -out flag to indicate ast json out location.
$ goastgen <filepath>/<go filename>

e.g
$ goastgen /path/src/hello.go 

It should generate the AST in JSON format at 

/path/src/.ast/hello.go.json
  1. Generate AST with single .go file with -out flag
$ goastgen -out <output location> <filepath>/<go filename>

e.g
$ goastgen -out /tmp/randompath /path/src/hello.go 

It should generate the AST in JSON format at 

/tmp/randompath/hello.go.json

Complete project directory

/path/repository
      - hello.go
      - anotherfile.go
      - somepkg
            - somelib.go
  1. Generate AST with above root directory of the go project without passing -out flag
$ goastgen <root directory location of go project>

e.g.
$ goastgen /path/repository

It should generate AST in JSON fromat for each .go file at following location

/path/repository/.ast
                  - hello.go.json
                  - anotherfile.go.json
                  - somepkg
                        - somelib.go.json      
  1. Generate AST with above root directory of the go project with -out flag
$ goastgen -out <output location> <root directory location of go project> 

e.g.
$ goastgen -out /temp/out/ /path/repository

It should generate AST in JSON fromat for each .go file at following location

/temp/out/
          - hello.go.json
          - anotherfile.go.json
          - somepkg
                - somelib.go.json      

goastgen's People

Contributors

pandurangpatil 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.