aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/go.rb
blob: 6f7bfafd52e5fd4103170fd52dcc4e4c0bdc843d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
require 'formula'

class Go <Formula
  head 'https://go.googlecode.com/hg/'
  homepage 'http://golang.org'

  aka 'google-go'

  skip_clean 'bin'

  def download_strategy
    MercurialDownloadStrategy
  end

  def cruft
    %w[src include test doc]
  end

  def install
    prefix.install cruft<<'misc'
    Dir.chdir prefix
    FileUtils.mkdir %w[pkg bin lib]

    ENV['GOROOT'] = Dir.getwd
    ENV['GOBIN'] = bin.to_s
    ENV['GOARCH'] = Hardware.is_64_bit? ? 'amd64' : '386'
    ENV['GOOS'] = 'darwin'

    ENV.prepend 'PATH', ENV['GOBIN'], ':'

    Dir.chdir 'src' do
      system "./all.bash"
    end

    FileUtils.rm_rf cruft
  end

  def caveats; <<-EOS
In order to use Go you need to set the following in your ~/.profile:

    export GOROOT=`brew --prefix`/Cellar/go/#{version}
    export GOARCH=#{ENV['GOARCH']}
    export GOOS=#{ENV['GOOS']}

Presumably at some point the Go developers won't require us to mutilate our
shell environments in order to compile Go code...
    EOS
  end
end