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
- Variables
- func DockerIgnore(root string) error
- func EscapeGoString(s string) string
- func Exec(line string, rest ...string) string
- func ExecLine(std bool, line string, rest ...string) string
- func GoTool(pkg string, args ...string) string
- func InstallNodeTools()
- func NodeTool(name string, args ...string) string
- func NodeToolOutput(name string, args ...string) string
- func ReadString(p string) (string, error)
- func S(tpl string, params ...interface{}) string
Constants ¶
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).
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 ¶
var TestEnvs = map[string]string{
"GODEBUG": "tracebackancestors=100",
}
TestEnvs for testing.
Functions ¶
func DockerIgnore ¶
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 ¶
EscapeGoString not using encoding like base64 or gzip because of they will make git diff every large for small change.
func ExecLine ¶
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 ¶
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 ¶
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 ¶
NodeToolOutput is NodeTool with the output captured rather than echoed, for a caller that parses it.
Types ¶
This section is empty.