PDA

View Full Version : Google Go Language on OSX 10.6




Nobita
Nov 12, 2009, 10:44 PM
Hi all,

Has any of you tried installing and running Go on your snow leopard? I tried the following tutorial:

http://www.kelvinwong.ca/2009/11/12/installing-google-go-on-mac-os-x-leopard/

and I think go has been installed now on my machine, but I can not seem to be able to run "gccgo" or "6g" or "8g" on my terminal... Is it under different alias/name?

Thank you all!



Cromulent
Nov 12, 2009, 10:58 PM
You probably just need to make sure it is in your $PATH.

Nobita
Nov 12, 2009, 11:03 PM
Hmm according to the guide I have to set path as:

export PATH=$GOBIN:$PATH

But then I realised that there is no such directory... I'm not sure what I should do...

Cromulent
Nov 12, 2009, 11:45 PM
$GOBIN is an environmental variable itself. You need to know what path it refers to in order to find out whether that path exists or not.

Nobita
Nov 13, 2009, 01:26 AM
$GOBIN is an environmental variable itself. You need to know what path it refers to in order to find out whether that path exists or not.

Well that doesn't really help, can you tell me what I should do now? Should I renew the definition of $PATH without using $GOBIN and reinstall Go?

Cromulent
Nov 13, 2009, 01:40 AM
Well that doesn't really help, can you tell me what I should do now? Should I renew the definition of $PATH without using $GOBIN and reinstall Go?

No you should do as the documentation says. If you don't know what path $GOBIN refers too then you can not state whether the path exists or not which was the original point of my post.

Type "echo $GOBIN" (without the quotes) to see where it points too. My guess would be /usr/local/bin

kainjow
Nov 13, 2009, 03:15 PM
I installed this and got it working.

I added this to my .bash_profile:

# Mercurial
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

# Go
export GOROOT="$HOME/Projects/go/root"
export GOBIN="$HOME/Projects/go/bin"
export GOOS="darwin"
export GOARCH="amd64"
export PATH="$GOBIN:$PATH"

Not sure if the Mercurial part was required but I did it anyway. If you know you're not on a 64-bit machine use i386 instead of amd64. ~/Projects/go/root is where the code is downloaded to, and ~/Projects/go/bin is where the binaries are placed once you compile them (of course this is how I set it up. You can put them anywhere you want).

Only error I came across was "FAIL: net.TestDialGoogle" but that was because my ISP is fail and switching to another network fixed it (thanks neighbors ;)).

Nobita
Nov 13, 2009, 07:36 PM
So I decided to uninstall everything (rm -r the go directories) and tried installing it again. This time I tried adding the mercurial part on my bash profile.

I downloaded go and I tried installing it by going to $GOROOT/src and then running ./all.bash

However I got this error message now, tried it three times and the same error message keeps happening:

--- FAIL: http.TestClient
Get http://www.google.com/robots.txt: dial tcp www.google.com:http: lookup www.google.com. on 192.168.1.1:53: no answer from server
--- FAIL: http.TestRedirect
Get http://codesearch.google.com/: dial tcp codesearch.google.com:http: lookup codesearch.google.com. on 192.168.1.1:53: no answer from server
FAIL
make[1]: *** [test] Error 1
make: *** [http.test] Error 2


Any clue, anyone? :(

kainjow
Nov 13, 2009, 08:38 PM
Try it on another network if you have one available. But it should be good now, as it's just running through the tests. Try continuing with the tutorial and see if the hello world compiles.

Nobita
Nov 13, 2009, 10:26 PM
Thank you, that fixed the problem of installing it.

Now I'm trying to compile a source code with the 6g command, but I can not seem to find 6g in my terminal!

-bash: 6g: command not found

I went to ~/go/bin/ and I found the following commands:

6nm 8c 8l ebnflint godoc gopack goyacc quietgcc
8a 8g cgo godefs gofmt gotest hgpatch

According to the tutorial, I need to use 6g, 6l, or gccgo, but where do I find those? I tried locating gccgo in the terminal, but had no luck!

~/go/.hg/store/data/doc/gccgo__contribute.html.i
~/go/.hg/store/data/doc/gccgo__install.html.i
~/go/.hg/store/data/doc/go__gccgo__setup.html.i
~/go/doc/gccgo_contribute.html
~/go/doc/gccgo_install.html

mathcolo
Nov 14, 2009, 12:34 AM
From the Google Go language web site:

6g is the Go compiler for amd64; it will write the output in file.6. The ‘6’ identifies files for the amd64 architecture. The identifier letters for 386 and arm are ‘8’ and ‘5’. That is, if you were compiling for 386, you would use 8g and the output would be named file.8.

You'll want to use the '8' ones because I presume you're using the i386 architecture.

Good luck!

Nobita
Nov 14, 2009, 12:44 AM
I see, thank you very much! I have just ran my hello world program =)

Btw why isn't gccgo working for me? is it working for any of you?

mathcolo
Nov 14, 2009, 01:14 AM
I see, thank you very much! I have just ran my hello world program =)

Btw why isn't gccgo working for me? is it working for any of you?

What about it isn't working for you?

Nobita
Nov 14, 2009, 01:15 AM
It's basically saying command not found... You have it working?

mathcolo
Nov 14, 2009, 01:18 AM
It's basically saying command not found... You have it working?

I get the same error, and I've noticed that gccgo isn't in the $GOBIN folder. It looks to me like it wasn't compiled with the rest of it (just like you, I think).

I'm not sure how to fix this, but I'll definitely post if I find anything.

Edit: Found the solution: http://golang.org/doc/gccgo_install.html

Nobita
Nov 14, 2009, 02:07 AM
I see, from the documentation I have got the impression that gccgo shouldn't be used for now. I think that's also the reason why they didn't include it by default...

Thank you then, I'll continue working through the tutorials and hopefully I could make something good out of this =)

Have a nice weekend everyone!