goutline

command module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2021 License: MIT Imports: 8 Imported by: 0

README

Goutline: Go AST Declaration Extractor

Simple utility for extracting a JSON representation of the declarations, for any code scope nesting in a Go source file.

Origin

Based on go-outline but adds:

  • nesting scopes support
  • go parser modes support

Installing

go get -u github.com/1pkg/goutline

Using

Optionally you can provide uint mode for go parser the -mode flag, by default mode equals to (4) ParseComments, see go parser Mode for more options and details.

> goutline -f file.go -mode 32
[{"label":"proc","type":"package",<...>}]

To parse unsaved file contents, use the -modified flag along with the -f flag and write an archive to stdin.
File in the archive will be preferred over the one on disk.

The archive entry consists of:

  • the file name, followed by a newline
  • the (decimal) file size, followed by a newline
  • the contents of the file

Schema

Declarations are provided as flatten list, with artificial package declaration at list head.

type Declaration struct {
	Label        string        `json:"label"`
	Type         string        `json:"type"`
	Start        token.Pos     `json:"start"`
	End          token.Pos     `json:"end"`
}

Licence

Goutline is licensed under the MIT License.
See LICENSE for the full license text.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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