<p>I'm looking to see if there's any workarounds for importing local go packages without dealing with gopath or go project structures. Someting like node_modules and require does, but for go. Thanks!</p>
<hr/>**评论:**<br/><br/>rangeCheck: <pre><p>vgo is mostly what you want (it needs gopath currently but that's "hidden" behind the scene and could use default value if you don't do anything)</p>
<p>vendoring doesn't need gopath, but you need some local path structure</p></pre>unix15e8: <pre><p>Packages are not required to be in the GOPATH in order to be imported. Whenever I need to import packages into my local directory, I just do something like <code>export GOPATH=$(pwd)</code> and continue working as if nothing had happened. Three new directories will be created: bin, pkg, src as described here [1]. Having your packages in GOPATH is just something "nice to have" because the majority of tools and IDEs out there assume your packages are there, but I have been working like this <em>(with the local GOPATH)</em> for +4 years now and haven't found any difference.</p>
<p>[1] <a href="https://golang.org/doc/code.html#remote" rel="nofollow">https://golang.org/doc/code.html#remote</a></p></pre>danredux: <pre><p>Go 1.8+ doesn't need GOPATH.</p>
<p>Also, generally, you don't need to care where the packages are. What issue are you running in to that you actually want to fix? "go get x.com/pkg" makes the package available, why are you concerned with it's final resting place?</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
0 回复
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传