[Advice] Project location question.

agolangf · · 710 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hi all. I just started at a new company that&#39;s been using Go since &#39;13 - before vendoring and standard directory structures. Their structure is a bit backwards from the standard structure, but we want to fix it.</p> <p>Our code is all stored in <code>$GOPATH/[project]/src/[company]/[package]</code>.</p> <p>Ex. <code>~/dev/myproject/src/acmecorp/mypackage</code></p> <p>I&#39;d like to re-org everything to be more standardized and switch to use dep.</p> <p>My question is this. Is it common practice to put <em>your</em> code in <code>$GOPATH/src/github.com/company/project/package</code>? Or can we skip the &#34;github.com&#34; part and just use <code>$GOPATH/src/company/project/package</code>?</p> <p>What problems or issues would we be getting ourselves into if we did that?</p> <p>Thanks in advanced</p> <hr/>**评论:**<br/><br/>insanelygreat: <pre><p>To quote the docs:</p> <blockquote> <p>In practice you can choose any arbitrary path name, as long as it is unique to the standard library and greater Go ecosystem.</p> </blockquote> <p>However, you lose the ability to <code>go get</code> packages you don&#39;t have.</p> <p>EDIT: <a href="https://golang.org/doc/articles/go_command.html#tmp_2" rel="nofollow">You&#39;ll probably find this helpful.</a></p></pre>sheepdog69: <pre><p>So, it would make sense to put any shared code into the full path (github.com/blah/blah)? So it&#39;s easier to use between projects?</p></pre>insanelygreat: <pre><p>I know it&#39;s verbose, but I&#39;d suggest putting everything under the domain. You&#39;ll be glad you did later.</p> <p>In case you missed my edit: <a href="https://golang.org/doc/articles/go_command.html#tmp_2" rel="nofollow">This section of the docs</a> explains the rationale.</p></pre>sheepdog69: <pre><p>That&#39;s for the feedback. I&#39;ll take a look at the link now.</p> <p>I definitely want to do it &#34;right&#34; from the beginning.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

710 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传