Documentation
¶
Overview ¶
Package gomod registers stripes renderers for the Go toolchain's flat-file formats: go.mod, go.sum, go.work, and vendor/modules.txt. Import for side effects:
import _ "github.com/firetiger-oss/stripes/gomod"
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenderMod ¶
RenderMod writes a styled rendering of the go.mod file read from r to w, with ANSI styling applied to directive keywords, module paths, versions, the `=>` replace operator, block parentheses, and `//` comments.
Parsing is done via golang.org/x/mod/modfile (lax mode), which handles block syntax, factored require/replace/exclude/retract/tool lists, inline comments, quoted module paths, and `// indirect` markers the same way the Go toolchain does.
func RenderSum ¶
RenderSum writes a styled rendering of the go.sum (or go.work.sum) file read from r to w. Each non-empty line has the shape:
<module-path> <version>[/go.mod] <hash>
The module path is styled as stripes.Styles.Anchor, the version as stripes.Styles.Number (with the optional `/go.mod` suffix as stripes.Styles.Syntax), and the hash as stripes.Styles.Code. Lines that don't match this shape fall back to plain stripes.Styles.Text rendering.
func RenderVendorModules ¶
RenderVendorModules writes a styled rendering of the vendor/modules.txt file read from r to w (the manifest produced by `go mod vendor`).
Line shapes:
- `## <annotation>` — annotation lines like `## explicit` or `## explicit; go 1.21`, styled as comments.
- `# <module> <version> [=> <replacement> [<version>]]` — module declaration lines; the `#` and `=>` are syntax, paths are anchors, versions are numbers.
- other non-blank lines — package import paths, styled as plain text.
- blank lines — preserved verbatim.
func RenderWork ¶
RenderWork writes a styled rendering of the go.work file read from r to w, with ANSI styling applied to directive keywords (`go`, `toolchain`, `use`, `replace`, `godebug`), module and directory paths, versions, the `=>` replace operator, block parentheses, and `//` comments.
Parsing is done via golang.org/x/mod/modfile.ParseWork; the token styling logic is shared with RenderMod.
Types ¶
This section is empty.