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 sogvin.com/goindex/cmd/...@latest
	
Index contents of a go file

    $ index complex.go
    complex.go 0 18 1 package testdata
    complex.go 18 43 3 import
    complex.go 43 80 8 // Decoupled comment
    complex.go 80 122 11 func NewBoat() *Boat 
    complex.go 122 189 17 type Boat struct 
    complex.go 189 218 21 type myHandler func(string)
    complex.go 218 258 23 type MyWriter interface 
    complex.go 258 420 29 func (b *Boat) Model() string 
    complex.go 420 442 37 func nada(int) error
    complex.go 442 531 39 func DoSomething(v interface{ X() }) (interface{ S() int }, error) 
    complex.go 531 552 43 // Decoupled comment


then grab Boat related sections using a combination of grep and grab

    $ index 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
    }