<p>What is the recommended way to organize a multi-language project?</p>
<p>Right now let's say I'm creating a project that will have javascript, ruby, and go.</p>
<p>The desired project structure would look like this. </p>
<pre><code>project
├── go
│ ├── lib
│ │ └── lib.go
│ └── main.go
├── js
│ ├── lib
│ │ └── lib.js
│ └── main.js
└── ruby
│ ├── lib
│ │ └── lib.rb
│ └── main.rb
</code></pre>
<p>Right now I've thought of a couple ways to get around this multi language debacle.</p>
<ul>
<li>Develop in the regular <code>$GOPATH</code>, <code>cp -r</code> project for every change.</li>
<li>Symlink <code>$GOPATH/project</code> into the multilanguage project</li>
<li><p>Develop under a new <code>$GOPATH</code> and change the structure to this for go.</p>
<pre><code>project
├── go
│ └── src
│ └── project
│ ├── lib
│ │ └── lib.go
│ └── main.go
├── js
│ └── main.js
└── ruby
└── main.rb
</code></pre></li>
</ul>
<p>Now all of these ways I've thought about getting around the <code>$GOPATH</code> issue have tradeoffs. Does anyone know of a good way around this that will get me close to the desired structure?</p>
<p>Thanks</p>
<hr/>**评论:**<br/><br/>jerf: <pre><p>You'll really want to go with the last one.</p>
<p>Basically, once you really get going you're going to discover that Ruby and JS also don't share the same ideal layout, and that you'll want to adopt a native layout for them, too. Just go with the most native answer for all of them. Go may be more obviously different but every language's ideal layout ends up different in the end, especially if you end up using their various package managers or deployment managers that want their own directory layout correctly.</p></pre>threemux: <pre><p>Agree with <a href="/u/jerf" rel="nofollow">/u/jerf</a>, you'll want to keep everything native if possible. Alternatively, you could use <a href="http://getgb.io/" rel="nofollow">gb</a>, which doesn't require the use of GOPATH at all and keeps the go code completely self contained. It does force you to use vendoring though, so if that's a turn off it might not be a good solution. </p></pre>DavidDavidsonsGhost: <pre><p>I personally prefer dividing up by components, because are you going to be looking for the thing in "go" or "SignupServer".</p></pre>yiyus: <pre><p>Why don't you go with the desired project structure? For example, if your project is in github.com/user/project, you can import lib as "github.com/user/project/go/lib". If you expect lib to be used by other developers, I would just have an independent repository for it, else I don't see what is the problem.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传