title: Multiple modules within the same project
body: <p>I've been playing with Go modules and I was wondering what the best practice is in terms of the following directory structure:</p>
  
  <pre><code>project
  ├── go.mod
  ├── main.go
  └── players
      ├── go.mod
      ├── players.go
      └── players_test.go
  </code></pre>
  
  <p>I was having problems importing the <code>players</code> package into my root project at first, but I noticed I could do this in the root <code>go.mod</code> file</p>
  
  <pre><code>module github.com/&lt;name&gt;/&lt;project&gt;
  
  require (
      github.com/&lt;name&gt;/players v0.0.0
  )
  
  replace github.com/&lt;name&gt;/players =&gt; ./players
  </code></pre>
  
  <p>This then allows me to do <code>import "github.com/&lt;name&gt;/players"</code> in my <code>main.go</code> file.</p>
  
  <p>Now this approach works and was taken from <a href="https://github.com/golang/go/wiki/Modules#can-i-work-entirely-outside-of-vcs-on-my-local-filesystem" rel="noreferrer">here</a> but I'm not sure if that's the correct approach for this or whether this approach is just meant for updating a local package temporarily while it's outside version control.</p>
  
  <p>Another option, that seems a little overkill, is to make every module its own repository?</p>
  
  <p>TL;DR; - What's the best practice approach to having multiple modules within the same repository and importing them in in other modules / a root <code>main.go</code> file?</p>