<p>I need (for research/class) to build a copy of Go without overwriting my Go compiler - i.e., I'd like to output a binary <code>go</code>in some folder that I can call without changing my path, overwriting my normal Go compiler, etc.</p>
<p>I feel like this should be really easy, since any Go compiler author must do it, but can't find any docs on this. </p>
<p>Help?</p>
<hr/>**评论:**<br/><br/>hariharan-uno: <pre><p>Refer <a href="https://golang.org/doc/install/source" rel="nofollow">https://golang.org/doc/install/source</a></p></pre>int32_t: <pre><p>TL;DR</p>
<p>$ git clone <a href="https://github.com/golang/go" rel="nofollow">https://github.com/golang/go</a></p>
<p>$ cd go/src</p>
<p>$ ./make.bash</p>
<p>The output binary resides in go/bin</p></pre>hipone: <pre><p>More complete TL;DR</p>
<pre><code>curl -sSL https://storage.googleapis.com/golang/go1.4.3.darwin-amd64.tar.gz | tar -C $HOME -zxf -
mv $HOME/{go,go1.4}
git clone --depth 1 git@github.com:golang/go $HOME/go1.5
cd $HOME/go1.5/src
./make.bash
ln -s $HOME/go{1.5,}
echo export GOROOT=\$HOME/go PATH=\$HOME/go/bin:\$PATH >> ~/.bash_profile
. ~/.bash_profile
</code></pre>
<p>If you would want to have multiple go compilers it's as easy as instaling them in $HOME/goX and just changing the $HOME/go symlink.</p></pre>GoTheFuckToBed: <pre><p>git clone <a href="https://github.com/golang/go" rel="nofollow">https://github.com/golang/go</a> --depth 1</p></pre>simplyh: <pre><p>Thanks for the help! For anyone else searching for this, compiling 1.5 from 1.5 seemed to not work until I set <code>GOROOT_BOOTSTRAP</code> to be <code>/usr/local/go</code>. From there it's as simple as compiling.</p></pre>int32_t: <pre><p>A minor tip in case you want to modify the code and do some experiments.</p>
<p><code>
$ go install cmd
</code></p>
<p>will rebuild the compiler toolchain solely.</p>
<p><code>
$ go install std
</code></p>
<p>will rebuild the standard library. And the output .a files reside in go/pkg/${YOUR_ARCH_AND_OS_COMBO} if I recall correctly.</p>
<p>Of course you can also enter individual package directory under <code>go/src/</code> and then type
<code>
go install
</code></p>
<p> </p>
<p><code>./make.sh</code> is usually used only for bootstrapping because it takes longer time.</p></pre>simplyh: <pre><blockquote>
<p>go install cmd</p>
</blockquote>
<p>THIS SAVED ME SO MUCH TIME</p>
<p>Jesus christ you're a godsend!</p></pre>lstokeworth: <pre><p>Follow the instructions at <a href="https://golang.org/doc/install/source" rel="nofollow">https://golang.org/doc/install/source</a>. The compiler and other tools are built to ./bin directory at the root of the repo.</p></pre>IrrelevantRaptor: <pre><p>You should use gvm</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传