Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/1pkg/goutline
Simple utility for extracting a JSON representation of the declarations, for any code scope nesting in a Go source file.
https://github.com/1pkg/goutline
go go-outline goutline
Last synced: about 10 hours ago
JSON representation
Simple utility for extracting a JSON representation of the declarations, for any code scope nesting in a Go source file.
- Host: GitHub
- URL: https://github.com/1pkg/goutline
- Owner: 1pkg
- License: mit
- Created: 2020-06-08T20:57:32.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-04-21T18:58:25.000Z (7 months ago)
- Last Synced: 2024-04-22T00:13:44.307Z (7 months ago)
- Topics: go, go-outline, goutline
- Language: Go
- Homepage:
- Size: 19.5 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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](https://github.com/ramya-rao-a/go-outline) but adds:
- nesting scopes support
- go parser modes support## Installing
```bash
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](https://golang.org/pkg/go/parser/#Mode) for more options and details.```bash
> 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.```go
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](LICENSE) for the full license text.