mx

package module
v0.0.47 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: 0BSD Imports: 9 Imported by: 0

README

mx: mage extras

go.dev reference Test license

  _ __ ___ __  __
 | '_ ` _ \\ \/ /
 | | | | | |>  <
 |_| |_| |_/_/\_\

SUMMARY

mx streamlines common Go development tasks for projects built with mage.

ABOUT

API Docs

mx provides utility functions for common Go development operations.

Examples:

  • GoEnv - Query the go env toolchain configuration subsystem
  • Install - Compile and install Go executables
  • Lint Go projects recursively:
    • GoImports
    • GoVet
    • GoVetShadow
    • Nakedret
  • UnitTest - trigger unit test suite
  • NoVendor - Query Go source file paths excluding vendoring
  • ExecSilent, RunVSilent - Reduce command log noise

SYSTEM REQUIREMENTS

For details on developing mx, see our development guide.

RESOURCES

Prior art and personal plugs.

🐱

Documentation

Overview

Package mx provides premade tasks for common mage workflows.

Index

Constants

View Source
const GoListSourceFilesTemplate = "{{$p := .}}{{range $f := .GoFiles}}{{$p.Dir}}/{{$f}}\n{{end}}"

GoListSourceFilesTemplate provides a standard Go template for querying a project's Go source file paths.

View Source
const GoListTestFilesTemplate = "{{$p := .}}{{range $f := .XTestGoFiles}}{{$p.Dir}}/{{$f}}\n{{end}}"

GoListTestFilesTemplate provides a standard Go template for querying a project's Go test file paths.

View Source
const Version = "0.0.47"

Version is semver.

Variables

This section is empty.

Functions

func CoverageHTML

func CoverageHTML(htmlFilename string, profileFilename string) error

CoverageHTML generates HTML formatted coverage data.

func CoverageProfile

func CoverageProfile(profileFilename string) error

CoverageProfile generates raw coverage data.

func ExecSilent added in v0.0.47

func ExecSilent(env map[string]string, program string, args ...string) error

ExecSilent executes commands with the UNIX / Go idiom of silencing output unless of an error.

func GoEnv

func GoEnv(key string) (string, error)

GoEnv queries the `go env` toolchain configuration system.

func GoImports

func GoImports(args ...string) error

GoImports runs goimports.

func GoVet

func GoVet(args ...string) error

GoVet runs go vet against all Go packages in a project.

func GoVetShadow

func GoVetShadow() error

GoVetShadow runs go vet against all Go packages in a project, with variable shadow checking enabled.

Depends on golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow

func Install

func Install(args ...string) error

Install builds and installs Go applications.

func Nakedret

func Nakedret(args ...string) error

Nakedret runs nakedret.

func RunVSilent added in v0.0.47

func RunVSilent(program string, args ...string) error

RunVSilent executes commands with the UNIX / Go idiom of silencing output unless of an error.

func Uninstall

func Uninstall(applications ...string) error

Uninstall deletes installed Go applications.

func UnitTest

func UnitTest(args ...string) error

UnitTest executes the Go unit test suite.

Types

type GoPaths added in v0.0.47

type GoPaths struct {
	// All collects Go source file paths.
	All map[string]bool

	// Regular collects non-unit-test Go source file paths.
	Regular map[string]bool

	// Test collects unit test Go source file paths.
	Test map[string]bool
}

GoPaths models information about Go project source trees.

func NewGoPaths added in v0.0.47

func NewGoPaths() GoPaths

NewGoPaths constructs a GoPaths.

func NoVendor added in v0.0.47

func NoVendor() (*GoPaths, error)

NoVendor queries Go source file paths, excluding vendored paths.

Jump to

Keyboard shortcuts

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