Simple utility for extracting a JSON representation of the declarations in a Go source file.
go get -u github.com/lukehoban/go-outline
> go-outline -f file.go
[{"label":"proc","type":"package",<...>}]
To parse and return only imports
> go-outline -f file.go -imports-only
type Declaration struct {
Label string `json:"label"`
Type string `json:"type"`
ReceiverType string `json:"receiverType,omitempty"`
Start token.Pos `json:"start"`
End token.Pos `json:"end"`
Children []Declaration `json:"children,omitempty"`
}