gotypes

--
import "vimagination.zapto.org/gotypes"
Package gotypes provides a helper function to parse Go types from source code.
Highlights
- Simple parsing of Go source code to enable reading of type information.
- Automatically handles dependencies, using local cache, stdlib, and remote Go mod proxy.
- Optionally omit specific source code files from parsing.
- Helper funcs to simplify common tasks.
Usage
package main
import (
"fmt"
"go/types"
"vimagination.zapto.org/gotypes"
)
func main() {
pkg, err := gotypes.ParsePackage(".")
if err != nil {
fmt.Println(err)
return
}
z := pkg.Scope().Lookup("zipFS")
fmt.Println(z)
for field := range z.Type().Underlying().(*types.Struct).Fields() {
fmt.Println(field)
}
}
Documentation
Full API docs can be found at:
https://pkg.go.dev/vimagination.zapto.org/gotypes