title: Can I run "go mod tidy" recursively?
body: <p>I have a Go repo which is like this:</p>
  <ul>
  <li>sdkpackage
  <ul>
  <li>go.mod</li>
  <li>_examples
  <ul>
  <li>one
  <ul>
  <li>go.mod</li>
  </ul>
  </li>
  <li>two
  <ul>
  <li>go.mod</li>
  </ul>
  </li>
  <li>three
  <ul>
  <li>go.mod</li>
  </ul>
  </li>
  </ul>
  </li>
  </ul>
  </li>
  </ul>
  <p>I wanted to have separate go.mod files as the main package is an SDK, and the examples are usage examples. They have dependencies that I don't want to reference in the main SDK package's <code>go.mod</code>.
  We need to support Go 1.12, and so don't want to use the GOPROXY approach outlined <a href="https://github.com/golang/go/wiki/Modules#should-i-have-multiple-modules-in-a-single-repository" rel="nofollow noreferrer">here</a> (yet)</p>
  <p>I want to build and tidy each module before committing, without having to do:</p>
  <pre class="lang-sh prettyprint-override"><code>go build ./...
  cd _examples/one
  go mod tidy
  cd ../_examples/two
  go mod tidy
  cd ../_examples/three
  go mod tidy
  </code></pre>
  <p>Obviously I can write a bash script to do this on a pre-commit hook, but is there any way to do this through a Go command, or a neater way?</p>
  <p>It looks like <code>go mod tidy</code> only has one option, (-v flag, prints info about removed modules), so wouldn't be suitable.</p>