Skip to content

dmrioja/gomodclean

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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...

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published