title: How to identify dependency chain using Go Modules
body: <p>How can I identify the import path of a module that exists in <code>go.sum</code> but not in <code>go.mod</code>? I'd like to know which module in <code>go.mod</code> is importing the module listed in <code>go.sum</code>, and the entire chain between them.</p>
  <p>I'm in the process of removing a deprecated module, <code>logrus</code>, from one of my modules and my own dependencies and want to ensure none of my own code still uses it, and which other code does use it.</p>
  <p>The Go module has both a <code>go.mod</code> and a <code>go.sum</code> file. In the <code>go.sum</code> file, a module <code>github.com/sirupsen/logrus</code> appears that does not appear in the <code>go.mod</code> file.</p>
  <p>When I recreate the <code>go.sum</code> file by deleting <code>go.sum</code> and running <code>go test -v ./...</code>, the <code>go.sum</code> file is recreated with <code>logrus</code>.</p>
  <p>There is no direct or indirect mention in <code>go.mod</code>, such as:</p>
  <pre><code>github.com/sirupsen/logrus v1.6.0 // indirect
  </code></pre>
  <p><code>go mod why</code> returns the following:</p>
  <pre><code>$ go mod why github.com/sirupsen/logrus
  # github.com/sirupsen/logrus
  (main module does not need package github.com/sirupsen/logrus)
  </code></pre>
  <p><code>go mod why -m</code> returns the following:</p>
  <pre><code>$ go mod why -m github.com/sirupsen/logrus
  # github.com/sirupsen/logrus
  (main module does not need module github.com/sirupsen/logrus)
  </code></pre>
  <p>How can I find out what module in <code>go.mod</code> is importing a module, <code>logrus</code>, which is listed in <code>go.sum</code> but not <code>go.mod</code>?</p>
  <p>Here's the module:</p>
  <ul>
  <li>Module: <a href="https://github.com/grokify/oauth2more" rel="noreferrer">https://github.com/grokify/oauth2more</a></li>
  <li><a href="https://github.com/grokify/oauth2more/blob/72b088f655853f0984d5933a699cef41812656df/go.mod" rel="noreferrer"><code>go.mod</code></a></li>
  <li><a href="https://github.com/grokify/oauth2more/blob/72b088f655853f0984d5933a699cef41812656df/go.sum" rel="noreferrer"><code>go.sum</code></a></li>
  </ul>