https://github.com/gregoryv/goindex
Tools to manipulate go source files
https://github.com/gregoryv/goindex
Last synced: 9 months ago
JSON representation
Tools to manipulate go source files
- Host: GitHub
- URL: https://github.com/gregoryv/goindex
- Owner: gregoryv
- License: mit
- Created: 2022-03-30T19:27:41.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-08-25T06:30:05.000Z (almost 2 years ago)
- Last Synced: 2025-08-23T10:32:45.202Z (10 months ago)
- Language: Go
- Homepage:
- Size: 451 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
- License: LICENSE
Awesome Lists containing this project
README
goindex - Package for indexing go files
This module provides tools to manipulate go source files by indexing
and extracting sections of code. This is useful when you are dealing
with large files and want to extract type related sections into a
separate file.

## Quick start
$ go install github.com/gregoryv/goindex/cmd/...@latest
Index contents of a go file
$ index complex.go
complex.go 0 18 package testdata
complex.go 18 31 import
complex.go 31 54 // Decoupled comment
complex.go 54 96 func NewBoat() *Boat
complex.go 96 132 type Boat struct
complex.go 132 282 func (me *Boat) Model() string
complex.go 282 369 func DoSomething(v interface{ X() }) (interface{ S() int }, error)
complex.go 369 392 // Decoupled comment
then grab Boat related sections using a combination of grep and grab
```shell
$ goindex complex.go | grep Boat | grab
func NewBoat() *Boat {
return &Boat{}
}
type Boat struct {
model string
}
// Func comment
func (b *Boat) Model() string {
if b.model == "" {
return fmt.Sprintf("%s", "unknown")
}
// Inline comment
return b.model
}
```