How to resolve import path when contributing to open source?

polaris · · 410 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>This might be a dumb question. But I am a beginner just starting to contribute to open source in some golang project.</p> <p>One thing I found that cause me alot of headache is that if the project has multiple package and the author uses those package across the packages its hard for me to resolve the import path when I fork the project.</p> <p>For example</p> <pre><code>package package2 import ( &#34;github.com/some_author/project_name/package1&#34; ) </code></pre> <p>If I change some code in package 1, the above will cause problem because the file I changed is in </p> <pre><code>&#34;github.com/my_github_name/project_name/package1&#34; </code></pre> <p>so this means that I have to manually change the author name if I change a package that rely on another package I also changed in the same repository</p> <p>I feel like I might be missing something. This cannot be the idiomatic way of open source contributing. I must be doing something wrong.</p> <hr/>**评论:**<br/><br/>nerr: <pre><p>Instead of working on a copy of the upstream repository (github.com/me/project), work on the repository itself (github.com/upstream/project). Add a new git remote that points to your fork, so you can push your changes to your fork (and then submit a pull request) when you&#39;re done.</p> <p>There is no need to ever touch an import path if you&#39;re planning on contributing upstream.</p></pre>problmeo: <pre><p>good point, I will try that, thanks.</p></pre>R2A2: <pre><p>I tend to name my remote the origin, and the upstream one upstream. It takes a couple more steps though.</p> <pre><code>git remote -v git remote rm origin git remote add origin https://github.com/me/project git remote add upstream https://(github.com/upstream/project git remote -v </code></pre></pre>daveddev: <pre><p>I wouldn&#39;t say that this is absolutely wrong, but it is certainly contrary to what the directory path implies.</p></pre>R2A2: <pre><p>For me it means I can keep the workflow I&#39;m used to. When I&#39;m working on a feature I just work with the origin as usual, then occasionally pull in changes from upstream, and PR back to upstream. It&#39;s much easier when context-switching IMO</p></pre>

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

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