Google Go Language on OSX 10.6

Discussion in 'Mac Programming' started by Nobita, Nov 12, 2009.

  1. Nobita macrumors 6502

    Joined:
    Oct 5, 2008
    Location:
    La la land
    #1
  2. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #2
    You probably just need to make sure it is in your $PATH.
     
  3. Nobita thread starter macrumors 6502

    Joined:
    Oct 5, 2008
    Location:
    La la land
    #3
    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...
     
  4. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #4
    $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.
     
  5. Nobita thread starter macrumors 6502

    Joined:
    Oct 5, 2008
    Location:
    La la land
    #5
    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?
     
  6. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #6
    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
     
  7. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #7
    I installed this and got it working.

    I added this to my .bash_profile:

    Code:
    # 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 ;)).
     
  8. Nobita thread starter macrumors 6502

    Joined:
    Oct 5, 2008
    Location:
    La la land
    #8
    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:

    Code:
    --- 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? :(
     
  9. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #9
    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.
     
  10. Nobita thread starter macrumors 6502

    Joined:
    Oct 5, 2008
    Location:
    La la land
    #10
    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:

    Code:
    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!

    Code:
    ~/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
     
  11. mathcolo macrumors 6502a

    Joined:
    Sep 14, 2008
    Location:
    Massachusetts
    #11
    From the Google Go language web site:

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

    Good luck!
     
  12. Nobita thread starter macrumors 6502

    Joined:
    Oct 5, 2008
    Location:
    La la land
    #12
    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?
     
  13. mathcolo macrumors 6502a

    Joined:
    Sep 14, 2008
    Location:
    Massachusetts
    #13
    What about it isn't working for you?
     
  14. Nobita thread starter macrumors 6502

    Joined:
    Oct 5, 2008
    Location:
    La la land
    #14
    It's basically saying command not found... You have it working?
     
  15. mathcolo macrumors 6502a

    Joined:
    Sep 14, 2008
    Location:
    Massachusetts
    #15
    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
     
  16. Nobita thread starter macrumors 6502

    Joined:
    Oct 5, 2008
    Location:
    La la land
    #16
    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!
     

Share This Page