devutil

package
v0.1.0-rc.4 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package devutil holds helpers for wand's generators and developer tools. It is not part of the public API: nothing under lib/ or the root package imports it except the generators that sit beside the packages they generate.

Index

Constants

View Source
const GolangciLint = "github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.15.0"

GolangciLint is the one pinned Go tool of the generators and the lint tool, run through GoTool. Its formatters (gofmt, gofumpt, goimports, gci) and its linters run at the versions its own go.mod pins, so moving this line moves them all together; the satellites' reusable workflow in headlesslab/.github pins the same version (spec #33, section 13: no @latest in a Gate).

View Source
const Govulncheck = "golang.org/x/vuln/cmd/govulncheck@v1.7.0"

Govulncheck is the vulnerability scanner of the security Gate, pinned here for the same reason: no Gate resolves a version at run time (spec #33, sections 13 and 16). The tool under internal/tools/govulncheck runs it; x/vuln's own Go floor is well above wand's, so only a recent toolchain can build it.

Variables

View Source
var TestEnvs = map[string]string{
	"GODEBUG": "tracebackancestors=100",
}

TestEnvs for testing.

Functions

func DockerIgnore

func DockerIgnore(root string) error

DockerIgnore writes the .dockerignore of the module at root from the .gitignore beside it, so that an image build context holds what a clean checkout holds and nothing more. The setup tool writes it as a step of go generate; the image build script writes it so that a build from a fresh clone needs no other step first.

func EscapeGoString

func EscapeGoString(s string) string

EscapeGoString not using encoding like base64 or gzip because of they will make git diff every large for small change.

func Exec

func Exec(line string, rest ...string) string

Exec command.

func ExecLine

func ExecLine(std bool, line string, rest ...string) string

ExecLine of command. It returns what the command wrote to its standard output; standard error is echoed when std is true and otherwise kept only for the panic message on failure, so that a caller parsing the output, such as the JS generator, is not confused by the "go: downloading" lines that go run prints on a cold module cache. Each stream gets a buffer of its own: os/exec serves two distinct writers from two goroutines, so a buffer they shared would be a data race (only one identical writer for both gets one goroutine).

func GoTool

func GoTool(pkg string, args ...string) string

GoTool runs a Go tool with args through go run, which builds it into the build cache on first use and installs nothing: a pinned tool by its module path at an exact version, such as GolangciLint, or a tool of this module by its package path. It echoes the output as well as returning it.

func InstallNodeTools

func InstallNodeTools()

InstallNodeTools installs the pinned Node tools from the lockfile.

func NodeTool

func NodeTool(name string, args ...string) string

NodeTool runs one of the pinned Node tools by its bin name from the module root, echoing its output as well as returning it.

func NodeToolOutput

func NodeToolOutput(name string, args ...string) string

NodeToolOutput is NodeTool with the output captured rather than echoed, for a caller that parses it.

func ReadString

func ReadString(p string) (string, error)

ReadString reads file as string.

func S

func S(tpl string, params ...interface{}) string

S Template render, the params is key-value pairs.

Types

This section is empty.

Jump to

Keyboard shortcuts

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