gomod

command module
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2021 License: MIT Imports: 15 Imported by: 0

README

Go Modules clarified

Build Status Maintainability Test Coverage

gomod is your one-stop-solution for making sense of your project's dependency graph. It supports the querying and visualising of the graphs of both your Go module dependencies as well as the underlying package import graph. It also comes with built-in analysis tools that extract information from the dependency graph that is usually hidden or hard to get to via other means.

Typical questions that gomod will help you answer are:

  • Why does my project have this module or package as a dependency.
  • What dependency chains lead to github.com/foo/bar and what constraints do they put on versions?
  • How old are the modules that my project depends on, and how much out-of-date are these?
  • Are different dependencies of my project using potentially conflicting forks of the same module?

Release-notes for each version can be found here

Table of Contents

Detailed features

Dependency analysis commands
gomod graph

Output your module dependency or package import graph in DOT format. You can filter out noise from the graph by tailoring your query to your needs. You can also add annotations to provide further information on the generated graph. By default gomod graph will act on the module graph, however by using the --packages flag it will consider the package import graph instead.

Querying the graph is done by means of a simple language that supports the following features:

Syntax Feature
github.com/foo/bar[/...] Filter based on exact paths or path prefixes.
github.com/foo/bar[/...]:test Include test-only dependencies matched by the specified pattern
deps|rdeps(<filter>[, <int>]) Consider all (reverse) dependencies of the elements matches by the nested filter, potentially limited to a certain depth.
shared(<filter>) Consider only nodes that have more than one predecessor (i.e are a dependency required by more than one source)
<filter> <operator> <filter> Perform a set-based operation (+, -, inter or delta) on the outcomes of the two given filters

Some examples:

  • Print the full dependency graph of this module (not including test-only dependencies):

    gomod graph 'deps(github.com/Helcaraxan/gomod)'
    
  • Print the graph of all dependencies, including test-only ones, that are required by more than one source.

    gomod graph 'shared(deps(github.com/Helcaraxan/gomod:test))'
    
  • Show only the dependency graph leading to the gopkg.in/yaml.v2 and gopkg.in/yaml.v3 modules:

    gomod graph 'rdeps(gopkg.in/yaml.v2:test + gopkg.in/yaml.v3:test)'
    
  • Show the same dependency graph as above but limited to the paths shared between both modules. Note that the resulting graph will not include the two targeted modules themselves.

    gomod graph 'rdeps(gopkg.in/yaml.v2:test) inter rdeps(gopkg.in/yaml.v3:test)'
    

If you want to create an image based on the generated text-based DOT content you need to use the dot tool which you will need to install separately.

gomod reveal

Show all the places at which your (indirect) module dependencies use replace statements which you might need to account for in your own go.mod in order to build your project.

gomod analyse

Produce a short statistical report of what is going on with your dependencies. The report includes things like (in)direct dependency counts, mean and max dependency ages, dependency age distribution, and more.

NB: This command can also be invoked as gomod analyze for those who intuitively use American spelling.

Example output

Full dependency graph

The entire dependency graph for the gomod codebase, using clustering to reduce the image size. Full dependency graph

Shared dependencies

Graph with only the shared dependencies for the gomod project. Shared dependencies graph

Dependency chains

Specific zoom on the dependency chains leading to the github.com/stretchr/testify module with version annotations. Annotated dependency chains for github.com/stretchr/testify

Hidden replace's

Revealing hidden replaces in the Matterbridge dependency graph. One is accounted for, the other is not. This can be the cause of unexpected errors when building the project.

 -> gomod reveal
'github.com/Rhymen/go-whatsapp' is replaced:
   maunium.net/go/mautrix-whatsapp -> github.com/tulir/go-whatsapp @ v0.0.2-0.20190528182350-fde573a2a73b

'gopkg.in/russross/blackfriday.v2' is replaced:
 ✓ maunium.net/go/mautrix            -> github.com/russross/blackfriday/v2 @ v2.0.1
 ✓ maunium.net/go/mautrix-appservice -> github.com/russross/blackfriday/v2 @ v2.0.1
 ✓ maunium.net/go/mautrix-whatsapp   -> github.com/russross/blackfriday/v2 @ v2.0.1

[✓] Match with a top-level replace in 'github.com/42wim/matterbridge'
Dependency statistics

Statistical analysis of the gomod dependency graph.

 -> gomod analyse
-- Analysis for 'github.com/Helcaraxan/gomod' --
Dependency counts:
- Direct dependencies:   10
- Indirect dependencies: 28

Age statistics:
- Mean age of dependencies: 15 month(s) 18 day(s)
- Maximum dependency age:   58 month(s) 17 day(s)
- Age distribution per month:

  18.42 % |          #
          |          #
          |          #
          |          #
          |    _   _ #   _   _
          |    #   # #   #   #
          |    #   # #   #   #
          |  _ # _ # # _ #   #     _
          |  # # # # # # #   #     #
          |# # # # # # # # # # #   #           #     #         #     #
   0.00 % |___________________________________________________________
           0                                                        60

Update backlog statistics:
- Number of dependencies with an update:  12 (of which 0 are direct)
- Mean update backlog of dependencies:    10 month(s) 4 day(s)
- Maximum update backlog of dependencies: 18 month(s) 4 day(s)
- Update backlog distribution per month:

  25.00 % |            #
          |            #
          |            #
          |            #
          |            #
          |            #
          |            #
          |  # #       # #     # #     #   # # #
          |  # #       # #     # #     #   # # #
          |  # #       # #     # #     #   # # #
   0.00 % |_____________________________________
           0                                  19

Reverse dependency statistics:
- Mean number of reverse dependencies:    1.42
- Maximum number of reverse dependencies: 4
- Reverse dependency count distribution:

  76.32 % |  #
          |  #
          |  #
          |  #
          |  #
          |  #
          |  #
          |  #
          |  #
          |  # # # _
   0.00 % |_________
           0       5

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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