mageextras

package module
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: BSD-2-Clause-Views Imports: 9 Imported by: 0

README

mage-extras: some predefined tasks for common mage workflows

EXAMPLE

$ mage noVendor
/Users/andrew/go/src/github.com/mcandre/mage-extras/test.go
/Users/andrew/go/src/github.com/mcandre/mage-extras/mageextras_test.go
/Users/andrew/go/src/github.com/mcandre/mage-extras/errcheck.go
/Users/andrew/go/src/github.com/mcandre/mage-extras/gofmt.go
/Users/andrew/go/src/github.com/mcandre/mage-extras/sources.go
/Users/andrew/go/src/github.com/mcandre/mage-extras/gox.go
/Users/andrew/go/src/github.com/mcandre/mage-extras/nakedret.go
/Users/andrew/go/src/github.com/mcandre/mage-extras/vet.go
/Users/andrew/go/src/github.com/mcandre/mage-extras/goimports.go
/Users/andrew/go/src/github.com/mcandre/mage-extras/mageextras.go
/Users/andrew/go/src/github.com/mcandre/mage-extras/packages.go
/Users/andrew/go/src/github.com/mcandre/mage-extras/pathseparator.go
/Users/andrew/go/src/github.com/mcandre/mage-extras/binaries_test.go
/Users/andrew/go/src/github.com/mcandre/mage-extras/sources_test.go
/Users/andrew/go/src/github.com/mcandre/mage-extras/binaries.go
/Users/andrew/go/src/github.com/mcandre/mage-extras/install.go

ABOUT

mage-extras defines some reusable task predicates for common workflows, in a platform-agnostic way:

  • security audits
  • checking that Go source code actually compiles
  • running unit tests
  • generating code coverage reports
  • linting with assorted Go linting tools
  • formatting Go code
  • installing and uninstall Go applications
  • collecting Go source file paths
  • obtaining the GOPATH/bin directory
  • referencing all local Go packages
  • referencing all local Go commands
  • cross-compiling applications with factorio, gox, goxcart, and xgo
  • archiving artifacts
  • manipulating the path separator as a string

Mage is highly agnostic about workflows. mage-extras is a little more opinionated, introducing some useful conventions on top, such as reliably obtaining a list of non-vendored Go files paths, while allowing developers to customize builds to suit their project needs.

DOCUMENTATION

https://godoc.org/github.com/mcandre/mage-extras

LICENSE

BSD-2-Clause

RUNTIME REQUIREMENTS

  • Mage (e.g., go install github.com/magefile/mage)
  • POSIX compatible tar
  • tree
  • a UNIX environment, such as macOS, Linux, BSD, WSL, etc.

tar is a portable archiver suitable for creating *.tgz tarball archives. Users can then download the tarball and extract the executable relevant to their platform. Tarballs are especially well suited for use in Docker containers, as the tar command is more likely to be installed than unzip.

Note that non-UNIX file systems may not preserve crucial chmod acl bits during port generation. This can corrupt downstream artifacts, such as compressed archives and installation procedures.

CONTRIBUTING

For more details on developing mage-extras itself, see DEVELOPMENT.md.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllCommandsPath = strings.Join([]string{".", "cmd", "..."}, PathSeparatorString)

AllCommandsPath denotes all Go application packages in this project.

View Source
var AllPackagesPath = strings.Join([]string{".", "..."}, PathSeparatorString)

AllPackagesPath denotes all Go packages in a project.

View Source
var CollectedGoFiles = make(map[string]bool)

CollectedGoFiles represents source and test Go files in a project. Populdated with CollectGoFiles().

View Source
var CollectedGoSourceFiles = make(map[string]bool)

CollectedGoSourceFiles represents the set of Go source files in a project. Populated with CollectGoFiles().

View Source
var CollectedGoTestFiles = make(map[string]bool)

CollectedGoTestFiles represents the set of Go test files in a project. Populdated with CollectGoFiles().

View Source
var 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
var 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
var LoadedGoBinariesPath = ""

LoadedGoBinariesPath denotes the path to the Go binaries directory. Populated with LoadGoBinariesPath().

View Source
var PathSeparatorString = string(os.PathSeparator)

PathSeparatorString models the os.PathSeparator as a string.

View Source
var Version = "0.0.16"

Version is semver.

Functions

func Archive

func Archive(portBasename string, artifactsPath string) error

Archive compresses build artifacts.

func CollectGoFiles

func CollectGoFiles() error

CollectGoFiles populates CollectedGoFiles, CollectedGoSourceFiles, and CollectedGoTestFiles.

Vendored files are ignored.

func Compile

func Compile(args ...string) error

Compile runs go build recursively.

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 DockerScout added in v0.0.14

func DockerScout(args ...string) error

DockerScout executes a docker security audit.

func Errcheck

func Errcheck(args ...string) error

Errcheck runs errcheck.

func Factorio

func Factorio(banner string, args ...string) error

Factorio cross-compiles Go binaries for a multitude of platforms.

func GoFmt

func GoFmt(args ...string) error

GoFmt runs gofmt.

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(args ...string) 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 LoadGoBinariesPath

func LoadGoBinariesPath() error

LoadGoBinariesPath populates LoadedGoBinariesPath.

func Nakedret

func Nakedret(args ...string) error

Nakedret runs nakedret.

func SnykTest

func SnykTest(args ...string) error

SnykTest executes a snyk security audit.

func Staticcheck

func Staticcheck(args ...string) error

Staticcheck runs staticcheck.

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.

func Unmake

func Unmake(args ...string) error

Unmake runs unmake.

func Xgo

func Xgo(outputPath string, args ...string) error

Xgo cross-compiles (c)Go binaries with additional targets enabled.

func Yamllint

func Yamllint(args ...string) error

Yamllint runs yamllint.

Types

This section is empty.

Jump to

Keyboard shortcuts

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