gomodclean

module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2025 License: MIT

README

gomodclean

Linter to check dependencies are well structured inside your go.mod file.

gomodclean gopher logo

Details

#1: Check require lines are grouped into blocks
BadGood
require github.com/bar/bar v2.0.0
require github.com/foo/foo v1.2.3
require (
    github.com/bar/bar v2.0.0
    github.com/foo/foo v1.2.3
)
Note:

If there is just one direct or indirect require directive, there is no need to encapsulate it into a require block, so the following example is valid:

require github.com/foo/foo v1.2.3

require (
    github.com/bar/bar v2.0.0 // indirect
    github.com/cosa/cosita v5.3.3 // indirect
)
#2: Check go.mod file only contains 2 require blocks
BadGood
require (
    github.com/foo/foo v1.2.3
)

require (
    github.com/bar/bar v2.0.0
)

require (
    github.com/cosa/cosita v5.3.3 // indirect
)
require (
    github.com/bar/bar v2.0.0
    github.com/foo/foo v1.2.3
)

require (
    github.com/cosa/cosita v5.3.3 // indirect
)
#3: Check the first require block only contains direct dependencies while the second one only contains indirect ones
BadGood
require (
    github.com/dmrioja/shodo v1.0.0 // indirect
    github.com/foo/foo v1.2.3
)

require (
    github.com/bar/bar v2.0.0
    github.com/cosa/cosita v5.3.3 // indirect
)
require (
    github.com/bar/bar v2.0.0
    github.com/foo/foo v1.2.3
)

require (
    github.com/cosa/cosita v5.3.3 // indirect
    github.com/dmrioja/shodo v1.0.0 // indirect
)

Usage

🚧 Work in Progress...

Directories

Path Synopsis
internal
io
pkg

Jump to

Keyboard shortcuts

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