Go: Install with Official package installer or use Homebrew??

polaris · · 687 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Looking to learn Go; as far as ease of headaches for installation and future updates, what is the best way to install Go? The official installer looks nice, but at the same time, I have read from other places that Homebrew is better and I&#39;m not sure which one to go with. Suggestions?</p> <hr/>**评论:**<br/><br/>CannedCorn: <pre><p>Use homebrew, you don’t have time to waste dicking around keeping this stuff up to date. Let homebrew handle it.</p></pre>ChristophBerger: <pre><p>That&#39;s also my reason for using Homebrew. And so far the <code>go</code> formula has always been kept up to date--I usually get new Go releases within a day or so.</p></pre>BOSS_OF_THE_INTERNET: <pre><p>Neither.</p> <pre><code>&gt; brew install wget &gt; wget https://storage.googleapis.com/golang/go1.9.darwin-amd64.tar.gz &gt; tar zxvf go1.9.darwin-amd64.tar.gz &gt; sudo mv go /usr/local/ </code></pre> <p>Set up your <code>GOPATH</code> (and possibly <code>GOROOT</code>) in your shell&#39;s env settings file, and you&#39;re done.</p> <p>There is nothing inherently wrong with doing it through homebrew or the package installer, but the simplicity of &#34;just drop it somewhere in your filesystem&#34; should not be overlooked. The only time this gets hairy is when you need to work in multiple versions of go, in which case I would let a tool like <a href="https://github.com/moovweb/gvm" rel="nofollow">gvm</a> handle it.</p></pre>muesli: <pre><p>Seems much more cumbersome than a <code>brew install go</code>. What would you consider the advantage of manually installing it over using a proper packagae manager?</p></pre>BOSS_OF_THE_INTERNET: <pre><p>Homebrew puts go into some path that I always tend to forget, like /usr/local/Cellar/go/...</p> <p>For me, the advantage is that I can run </p> <pre><code>brew update &amp;&amp; brew upgrade </code></pre> <p>without breaking anything.</p></pre>muesli: <pre><p>Cellar is the path where brew installs everything, so I&#39;m not sure how one can forget that. I&#39;ve been using <code>brew update/upgrade</code> with go installed just fine and nothing breaks.</p></pre>DocPorter: <pre><p>Whoa, this is news to me. So when the time comes for me to update, I just need to run this same command(s) again? Will it overwrite the preexisting version when I have to update?</p></pre>sh41: <pre><p>When it comes time to update, remove the old directory, then move/extract the new version into same place. If you don&#39;t remove old version, you might inherit files from old version that weren&#39;t kept in new.</p> <p>This is what I do to install Go on new computers (usually VMs):</p> <pre><code># Install Go on Linux. sudo rm -rf /usr/local/go &amp;&amp; curl -L https://golang.org/dl/go1.9.linux-amd64.tar.gz | sudo tar zx -C /usr/local/ # Add to ~/.bash_profile. export PATH=&#34;$PATH:/usr/local/go/bin:$HOME/go/bin&#34; </code></pre></pre>DocPorter: <pre><p>Thanks!</p></pre>fmpwizard: <pre><p>when a new version is released, you need to first delete the old /usr/loca/go folder, as there are times when having files from an older version cause issues, but other than that, yes, just those few commands and you are ready to go :)</p></pre>DocPorter: <pre><p>Thanks!</p></pre>BOSS_OF_THE_INTERNET: <pre><p>You would just remove the existing directory (<code>/usr/local/go</code>), but yeah that&#39;s how you would do it. Again, if you need to work with multiple versions, a version-switching tool might be more what you&#39;ll need. But if you only care about one single Go version, then you can&#39;t get much simpler.</p></pre>DocPorter: <pre><p>Thanks!</p></pre>victorestupadre: <pre><p>The regular installer couldn&#39;t be simpler. Installing new versions is handled fine with the latest download. No need to remove first. I wouldn&#39;t fret it.</p></pre>DocPorter: <pre><p>thanks!</p></pre>chulkilee: <pre><p>Go from homebrew is not from the official package. You don&#39;t need to compile it though (as Homebrew uses precompiled one)</p> <p>Go was in homebrew cask but has been removed. Homewbrew cask does not accept go since other homebrew packages (not cask packages) may depend on go and there is no way in homebrew to use go from cask to build homebrew package. </p> <p>See <a href="https://github.com/caskroom/homebrew-cask/pull/31728" rel="nofollow">https://github.com/caskroom/homebrew-cask/pull/31728</a> for details. </p> <p>I wanted to use the official package and manage it with homebrew cask, I just created my own tap. I don&#39;t install any homebrew package which needs homebrew go so jt just works. </p></pre>daenney: <pre><p>What&#39;s not official about it? The <a href="https://github.com/Homebrew/homebrew-core/blob/master/Formula/go.rb" rel="nofollow">formula</a> uses <a href="https://storage.googleapis.com/golang/" rel="nofollow">https://storage.googleapis.com/golang/</a> to fetch the binaries from or uses <a href="https://go.googlesource.com/go.git" rel="nofollow">https://go.googlesource.com/go.git</a> when a head/source build is triggered. It&#39;s all fetched from the authoritative sources.</p></pre>chulkilee: <pre><p>It does not use the official <em>installer package</em> file - <code>.pkg</code>. It does not use the official binaries neither. It only downloads the 1.7 binaries to bootstrap the go build env.</p> <p>That&#39;s what I&#39;m saying it is not using the official package. I was not saying it isn&#39;t using the authoritative sources. </p></pre>daenney: <pre><p>But why does that matter at all? What&#39;s the benefit you get from use the <code>.pkg</code>?</p></pre>chulkilee: <pre><p>Nothing special. I just want to use the official binaries. I’m not saying I don’t trust precompiled bottle from Homebrew :)</p></pre>rggarou: <pre><p>In a development environment I use the <a href="https://github.com/asdf-vm/asdf" rel="nofollow">asdf</a>. But it would be overkill if you are going to work with go only.</p></pre>barney74: <pre><p>2 cents here. I avoid Homebrew like the plague. I use to use it until it messed up installs on me several times. Since then I have been grabbing official installers and never looking back.</p></pre>4ad: <pre><p>Avoid homebrew like the plague.</p></pre>

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

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