gomod

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2026 License: MIT Imports: 7 Imported by: 0

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

func RenderMod(w io.Writer, r io.Reader, styles *stripes.Styles)

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

func RenderSum(w io.Writer, r io.Reader, styles *stripes.Styles)

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

func RenderVendorModules(w io.Writer, r io.Reader, styles *stripes.Styles)

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

func RenderWork(w io.Writer, r io.Reader, styles *stripes.Styles)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL