<p>I've got a lib, <a href="https://github.com/mcandre/go-ios7crypt" rel="nofollow">https://github.com/mcandre/go-ios7crypt</a>, with an accompanying command line tool, <a href="https://github.com/mcandre/go-ios7crypt/tree/master/cmd/ios7crypt" rel="nofollow">https://github.com/mcandre/go-ios7crypt/tree/master/cmd/ios7crypt</a>, that I like to hack on.</p>
<p>I often want to tweak the code, rebuild the library, rebuild the command line binary, install, and try out the command line binary. I've been pushing commits to GitHub and <code>go get -u github.com/mcandre/go-ios7crypt && go install github.com/mcandre/go-ios7crypt/cmd/ios7crypt</code> for every little change, and it's not fun.</p>
<p>Are there more better<code>go</code>... commands I can use to rebuild and reinstall my stuff directly from my local git repo checkout, rather than pushing my stuff to GitHub first?</p>
<hr/>**评论:**<br/><br/>djherbis: <pre><p>If you are modifying your code under:
$GOPATH/src/github/mcandre/go-ios7crypt</p>
<p>Then go install github.com/mcandre/go-ios7crypt/cmd/ios7crypt is using your local lib. You shouldn't have to go get every time, if the changes are already being made locally.</p></pre>mcandre: <pre><p>For reasons, I prefer not to keep all my projects in $GOPATH. Could I soft link or something?</p></pre>TheMerovius: <pre><p>Your reasons are probably bad reasons.</p>
<p>Nevertheless, yes, you can create symlinks from wherever you are keeping your code into the appropriate $GOPATH directory. You'll still want to develop from there, because otherwise go treats this as an out-of-tree build (as it looks at <code>.</code>) which might have undesirable side-effects.</p>
<p>Really, if you don't want to fight with the tooling, you shouldn't fight with the tooling and just use $GOPATH the way as it was intended.</p></pre>mcandre: <pre><blockquote>
<p>if you don't want to fight with the tooling</p>
</blockquote>
<p>Too late. Go's tooling has gotten much better than it once was (remember when we had to use multiple Makefiles to compile Go code, before <code>go build</code> was a thing?) However, Go should reexamine how it checks whether a directory is "in" $GOPATH. Simply expanding GOPATH into an absolute path and testing whether cwd is a direct child of GOPATH excludes symlinks, i.e., the tooling is fighting tried-and-true Unix file system standards.</p>
<p>I wouldn't even be <em>discussing</em> soft links and other hacks in the context of other programming languages, because other package managers like NPM don't require such nonsense. <em>Go</em> is the problem here.</p></pre>mixedCase_: <pre><p>Soft linking isn't a hack. It's a unix tool like any other.</p>
<p>I can access all my projects at $HOME/code but many of them exist in a different place, including all the Go code I touch which lie in a $HOME/.go folder.</p>
<p>NPM has its own downsides, and if you want NPM's way of dealing with things you vendor absolutely everything and stop complaining about go getting stuff.</p></pre>mcandre: <pre><p>Hmm, maybe my symlinks are misconfigured in Windows. Do I need to use a junction? Anyone have success symlinking local git repo directories into GOPATH in Windows?</p></pre>ohaiyou_meepo_desu: <pre><blockquote>
<p>Your reasons are probably bad reasons.</p>
</blockquote>
<p>I don't like how Go treats me like I'm retarded in that sense. Go is a cruel, but very enjoyable mistress.</p></pre>djherbis: <pre><p>I always just use GOPATH, but maybe <a href="https://getgb.io/" rel="nofollow">gb</a> would help?</p></pre>mcandre: <pre><blockquote>
<p>gb projects can be retrieved using go get, but cannot be built by the go tool as they do not follow the convention required by go get.</p>
</blockquote>
<p><a href="https://getgb.io/docs/project/" rel="nofollow">https://getgb.io/docs/project/</a></p>
<p>Worrisome.</p></pre>djherbis: <pre><p>Go is opinionated about how things are done. They may not always be what's "best" by your standard, but if you do them the Go way, they will work easily within the Go setup.</p>
<p>You can't really get the best of both worlds with this, you either have to use GOPATH, and have go get work they way you want. Or use a package manager (like gb) and do things their way.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传