title: Why does `go list -mod=readonly -m all` require access to private repos?
body: <p>I'm trying to print a list of direct dependencies in a Go project that has a vendor directory with:</p>
  <pre><code>go list -mod=readonly -m -f '{{ if not .Indirect }}{{ .Path }}{{ end }}' all
  </code></pre>
  <p>As I understand, I have to use <code>-mod=readonly</code> because <code>go list</code> refuses to report <a href="https://github.com/golang/go/blob/master/src/cmd/go/internal/list/list.go#L508_L513" rel="nofollow noreferrer">based on the partial information in vendor</a>. This works on my laptop, because I have access to the private repo <code>github.com/monzo/argo-rollouts</code>, but in CI it fails with:</p>
  <pre><code>go list -m: github.com/argoproj/argo-rollouts@v0.0.0-20220309162305-84c86ea52e8f (replaced by github.com/monzo/argo-rollouts@v0.0.0-20220309162305-84c86ea52e8f): version &quot;v0.0.0-20220309162305-84c86ea52e8f&quot; invalid: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /home/circleci/go/pkg/mod/cache/vcs/052bf06be1713582ba9f1144e9982b362ff355fec71675863c108f9cf5a00bb4: exit status 128:
      ERROR: Repository not found.
      fatal: Could not read from remote repository.
      
      Please make sure you have the correct access rights
      and the repository exists.
  </code></pre>
  <p>Why does <code>go list -mod=readonly</code> need access to the private repo? I haven't provided <code>-u</code>.</p>
  <p>Also, why can't it get this information locally when in vendor mode?</p>
  <p>Edit: I've found a workaround that passes eligible modules to <code>go list -m</code> in vendor-mode, but it involves parsing the unstable vendor/modules.txt file intended for machines only.</p>
  <pre><code>% cat modules-that-provide-packages.awk
  BEGIN {
          mod = &quot;&quot;
  }
  
  # Remember the module
  /^# / {
          mod = $2
  }
  
  # Print the module if it provides a package
  !/^# / {
          print mod
  }
  
  
  % awk -f modules-that-provide-packages.awk vendor/modules.txt /
      | sort -u \
      | xargs go list -m -f '{{ if not .Indirect }}{{ .Path }}{{ end }}'
  </code></pre>