Documentation
¶
Overview ¶
Package gocode is the Go backend for `sf code`: a structural summary of a Go source file (package, imports, types, func/method signatures, consts, vars) and single-symbol slicing — via the stdlib go/parser (syntax only, no type-checking), so it works on any file regardless of whether it compiles.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Slice ¶
Slice returns the source of one named symbol (signature + body + doc) from src, or the available names when not found.
func Summarize ¶
Summarize writes the structural summary of the Go file at path to w in the given format (toon|md|json) and returns a call-log summary map. api (PHP's effective-surface flag) is not meaningful for Go and is ignored. brief requests the signature-only cut — see Brief for exactly what it drops.
Types ¶
type GoFile ¶
type GoFile struct {
File string `json:"file"`
Package string `json:"package"`
Imports []string `json:"imports"`
Types []GoType `json:"types"`
Funcs []GoFunc `json:"funcs"` // free funcs and methods (Recv set)
Consts []GoValue `json:"consts,omitempty"`
Vars []GoValue `json:"vars,omitempty"`
}
GoFile is the structural summary of one Go source file.
func ReadGo ¶
ReadGo parses a single Go file (syntax only — no type-checking, no build), so it works on any file regardless of whether its package compiles.
func (*GoFile) Brief ¶ added in v0.6.0
func (g *GoFile) Brief()
Brief collapses field/value-level detail for a signature-only view: struct field lists (and their tags) disappear — kind and name stay — while interface Detail is left alone (it's already just method signatures, the same level of detail as a free func's Sig). Consts and vars drop their type column, leaving bare names — the const/var equivalent of a struct's fields, and no more useful in a whole-package map. Composes with FilterExported in either order.
func (*GoFile) FilterExported ¶
func (g *GoFile) FilterExported()
FilterExported drops unexported (lowercase) symbols, leaving the API view.