Giter VIP home page Giter VIP logo

gomod's Introduction

Go Modules clarified

License: MIT Build Status Maintainability Test Coverage

gomod is a tool that helps Go project maintainers to understand their project's dependencies and it can provide useful information to developers "modularising" non-module projects. It helps you by visualising your dependency graph and, even more, analyse it for your profit. It will help you answer typical questions such as:

  • How can I visualise the network of my dependencies?
  • How old are the versions of my dependencies that I depend on?
  • Are different dependencies of my project using potentially conflicting forks of the same module?
  • What dependency chains lead to github.com/foo/bar and what constraints do they put on versions?
  • Why is dependency github.com/foo/bar used at version 1.12.0 and not at version 1.5.0 as I want it to be?

Release-notes for each version can be found here

Table of Contents

Detailed features

Dependency analysis commands

gomod graph

Create a graphical representations of your dependency graph with the possibility to filter out noise, add annotations and focus on the pieces of the graph that are of interest to you. You can for example:

  • Only show dependencies that are required by more than one module.
  • Only show the dependency chains that lead to one or more specified modules.
  • Annotate dependencies with the versions in which they are used and the versions constraint imposed by each edge of the graph.

This functionality requires the dot tool which you will need to install separately. You can produce images in GIF, JPG, PDF, PNG and PS format.

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.

Command-line use

The sub-commands of gomod completion provide you with the benefit of shell auto-completion making it easier to cycle through the available sub-commands and flags.

Bash

Besides completion for static elements such as commands and flags, the auto-complete functionality for Bash also provides some context-specific completion such as the dependency names of your current project.

If you only want completion to be added to your current shell you can simply run

source <(gomod completion bash)

If you want to have it added by default to each shell instance that you start you can add the following to your .bashrc, .profile (Linux) or .bash_profile (MacOS / OSX)

# Provide Bash auto-completion for the 'gomod' tool if it's in the PATH.
if [[ -n "$(which gomod)" ]]; then
   source <(gomod completion bash)
fi

Powershell

In order to auto-completion by default to each shell instance that you start you can add the following to your PowerShell profile

if (Get-Command "gomod" -errorAction SilentlyContinue) {
   $tmp = New-TemporaryFile
   gomod completion ps | Out-File $tmp.FullName
   . $tmp.FullName
   Remove-Item $tmp.FullName
}

ZSH

If you only want completion to be added to your current shell you can simply run

source <(gomod completion zsh)

If you want to have it added by default to each shell instance that you start you can add the following to your .bashrc, .profile (Linux) or .bash_profile (MacOS / OSX)

# Provide ZSH auto-completion for the 'gomod' tool if it's in the PATH.
if [[ -n "$(which gomod)" ]]; then
   source <(gomod completion zsh)
fi

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 and golang.org/x/sys modules 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

gomod's People

Contributors

helcaraxan avatar tomor avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.