modfmt

command module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2025 License: MIT Imports: 5 Imported by: 0

README

modfmt

This tool merges require blocks in go.mod files since go mod tidy doesn't do it. It also separates the direct and indirect dependencies and sorts them alphabetically.

Before After

Installation

go install github.com/PaddleHQ/modfmt@latest

Usage

The binary outputs the formatted go.mod to standard output. In your Go project root, run:

go run github.com/PaddleHQ/modfmt@latest

You can also replace the go.mod file in place with the --replace flag:

go run github.com/PaddleHQ/modfmt@latest --replace

Limitations

I hacked this tool together using the official parser in less than 2 hours and unsurprisingly there are a few drawbacks with this:

  • require blocks come last after using this. Can be fixed with little effort I think?
  • Comments in require blocks are not preserved.

Documentation

Overview

Package main is responsible for handling CLI entrypoint of modfmt

Directories

Path Synopsis
pkg
modfmt
Package modfmt provides methods for formatting go.mod files
Package modfmt provides methods for formatting go.mod files

Jump to

Keyboard shortcuts

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