tidyall

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 18 Imported by: 0

README

go-tidy-all

GitHub Release autofix.ci Verify (App) Verify (Actions) CodeQL Advanced Trivy codecov

Tidy every go.mod file in your repo.

What it does

  • Finds every go.mod under the current directory.
    • Skips what .gitignore (and .git) already ignores.
  • Runs go mod tidy in each module.
  • Sets each go directive to the lowest version your code actually needs (via mingo).

Install

go install github.com/logica-oss/go-tidy-all/cmd/go-tidy-all@latest

Or grab a binary from Releases (linux/darwin × amd64/arm64):

VERSION=vX.Y.Z # pick from Releases
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m | sed -e 's/x86_64/amd64/' -e 's/aarch64/arm64/')

curl -fsSL "https://github.com/logica-oss/go-tidy-all/releases/download/${VERSION}/go-tidy-all_${VERSION#v}_${OS}_${ARCH}.tar.gz" | tar -xz go-tidy-all
sudo install -m 755 go-tidy-all /usr/local/bin/

Usage

Usage: go-tidy-all [options]

Run go mod tidy for every module and pin each go directive.

Options:
  -n, --dry-run                 print planned changes without writing
      --min-go-version string   pin the go directive to at least this version (e.g. 1.24.0)
      --root string             repository root (default: current directory)
      --skip-dirs string        comma-separated root-relative directories to skip
  -v, --version                 print version and exit

It exits non-zero when no modules are found.

# Tidy a specific repo, skip fixtures, keep go 1.24+:
go-tidy-all --root /path/to/repo --skip-dirs e2e/testdata --min-go-version 1.24.0

# Preview only:
go-tidy-all -n

Documentation

Overview

Package tidyall runs go mod tidy for every module and pins each go directive to the lowest version that mingo computes.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoModule = errors.New("no go.mod found")

ErrNoModule is returned when no go.mod is found under the root.

Functions

func Run

func Run(ctx context.Context, log *slog.Logger, cfg Config) error

Run tidies every module under root.

Types

type Config

type Config struct {
	// Root is the repository root.
	Root string
	// DryRun prints planned changes without writing.
	DryRun bool
	// SkipDirs skips modules under these root-relative directories.
	SkipDirs []string
	// MinGoVersion pins the go directive to at least this version (e.g. "1.24.0").
	// Empty follows the mingo result.
	MinGoVersion string
}

Config holds tidy-all settings.

Directories

Path Synopsis
cmd
go-tidy-all command
Command go-tidy-all runs go mod tidy for every module and pins each go directive to the lowest version that mingo computes.
Command go-tidy-all runs go mod tidy for every module and pins each go directive to the lowest version that mingo computes.

Jump to

Keyboard shortcuts

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