<p>I started learning Go yesterday. One thing that ground my gears was having a separate workspace for Go code apart from my other projects. So I wrote some scripts that can be installed and run in Powershell, cmd, and bash. They set/unset the directory where the scripts were invoked as a Go workspace. They do not make any persistent changes to the system. </p>
<p>I'd appreciate any feedback. <a href="https://github.com/hazrmard/goinit" rel="nofollow">You can find them here.</a></p>
<hr/>**评论:**<br/><br/>knotdjb: <pre><p>Go programmers typically keep all their Go code in a single <em>workspace</em>.</p>
<p><a href="https://golang.org/doc/code.html" rel="nofollow">source</a></p></pre>HazrMard: <pre><p>Yes. I read about the convention. However I, and I suspect many others group their code by project and not language. These scripts allow me to be consistent with my code organization. </p>
<p>I think Go is unique in this requirement. Perhaps some more exposure will help me get used to the standard way.</p></pre>knotdjb: <pre><p>Not only is a workspace useful for building code, but the packages and tools which you 'go get' reside in that workspace. For example, I use goconvey, gometalinter, whatever vim-go requires, etc.</p>
<p>With multiple workspaces I would need to redo the effort each time.</p></pre>ChristophBerger: <pre><p>A good compromise between a single GOPATH and per-project GOPATHs is the two-part GOPATH as described in <a href="https://peter.bourgon.org/go-best-practices-2016" rel="nofollow">this awesome best-practices writeup</a>.</p>
<p>TL;DR:</p>
<blockquote>
<p>Some Go developers use a two-entry GOPATH, e.g. $HOME/go/external:$HOME/go/internal. The go tool has always known how to deal with this: go get will fetch into the first path, so it can be useful if you need strict separation of third-party vs. internal code.</p>
</blockquote></pre>daveddev: <pre><p>These may offer some help/inspiration.</p>
<p><a href="https://github.com/moovweb/gvm" rel="nofollow">https://github.com/moovweb/gvm</a></p>
<p><a href="https://getgb.io" rel="nofollow">https://getgb.io</a></p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传