astree

package module
v0.0.0-...-47f8e4c Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2022 License: MIT Imports: 4 Imported by: 1

README

astree

tree command for Go AST

install

go get -u github.com/knsh14/astree/cmd/astree

options

Example

https://play.golang.org/p/up3cRnFCm61

package main

import (
	"go/parser"
	"go/token"
	"log"
	"os"

	"github.com/knsh14/astree"
)

func main() {
	code := `
package main

import (
	"fmt"
)

func main() {
	fmt.Println("Hello, playground")
}`
	fs := token.NewFileSet()
	f, err := parser.ParseFile(fs, "main.go", code, 0)
	if err != nil {
		log.Fatal(err)
	}
	astree.File(os.Stdout, fs, f)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func File

func File(w io.Writer, fs *token.FileSet, node *ast.File) error

File prints AST of one file

func Node

func Node(w io.Writer, fs *token.FileSet, node ast.Node)

Node prints AST node

func Packages

func Packages(w io.Writer, fs *token.FileSet, pkgs map[string]*ast.Package) error

Packages prints AST of result from go/parser.ParseDir

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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