Re: Installing Go

824 views
Skip to first unread message

Archos

unread,
Mar 8, 2013, 5:29:34 PM3/8/13
to golan...@googlegroups.com
Installation in Ubuntu / Debian
========================

Read introduction in http://golang.org/doc/install.html#introduction
And http://code.google.com/p/go-wiki/wiki/GOPATH


## Install development environment

To build Go it's necessary the C tools:

    sudo apt-get install build-essential -y
    sudo apt-get install bzr git mercurial -y

### Set variables

I've choosen '/opt/' as directory to hold the Go core:

    sudo mkdir -p /opt/go /opt/go-3pkg/src
    sudo chown :sudo -R /opt/go /opt/go-3pkg
    sudo chmod g+w /opt/go /opt/go-3pkg /opt/go-3pkg/src

    cat >> ~/.bashrc << 'EOF'

    ## Go language
    export GOROOT=/opt/go
    export GOPATH=/opt/go-3pkg:~/go
    export PATH=$PATH:$GOROOT/bin:${GOPATH//://bin:}/bin

    alias go-release="cd $GOROOT && hg pull && hg update release; cd -"
    alias go-build="cd $GOROOT/src && ./all.bash && cd -"
    EOF

**Now, it's necessary to re-start the seesion.**

Once it has rebooted, the *GOROOT* output should be checked:

    env |grep ^GO


## Install Go

    hg clone -r release https://go.googlecode.com/hg/ $GOROOT
    go-release
    go-build

Now, should be possible to access to Go commands; run:

    go version


## Upgrade Go

+ Update to the last release:

      go-release

+ Compile:

      go-build

+ Reinstall all packages "goinstalled" after an upgrade of Go core:

      go install -a


## Install local software

    mkdir -p ~/go/src/

Try installing an external package:
    go install -v github.com/...


El viernes, 8 de marzo de 2013 21:07:40 UTC, James Richardson escribió:
Hi I was wondering if there is a good link about that has the whole process from start to finish for installing go, goclipse & gocode on windows that works I have been trying for 2 days but I seam to get one problem after another and most info to sort problems out are to do with linux.

All the install's guides are either badly done or pointing to 5-6 different pages to do a little here and there.

With the current setup when I import ftm (or anything else) it says cannot find package and gocode dose not give code hinting or auto complete.

any help would be much appreciated.

James.

James Richardson

unread,
Mar 8, 2013, 5:37:23 PM3/8/13
to golan...@googlegroups.com
Thanks for the reply but as I stated I am looking for installation on windows or a fix for the problem I am having importing packages into go? I don't rely want to reinstall my computer with ubuntu or debian just to get this working.

Archos

unread,
Mar 8, 2013, 5:47:45 PM3/8/13
to golan...@googlegroups.com
Sorry! I didn't read all of your message else "linux" and I though that your problem was there.

What Windows version do you have? Because I could install Go on Windows XP under VirtualBox.

James Richardson

unread,
Mar 8, 2013, 5:56:57 PM3/8/13
to golan...@googlegroups.com
Windows 7 64bit

I was going to install ubuntu in VirtualBox but I would prefer to get it working under windows.

Archos

unread,
Mar 8, 2013, 6:06:26 PM3/8/13
to golan...@googlegroups.com
These are my notes about when I've to install it in Win XP to configure it. It may help to you.
Change "neo" by your user name. Good luck!

* * *

#### Windows

These are programs that I had to install:

http://7-zip.org/
http://www.kpym.com/2/kpym/index.htm
http://mercurial.selenic.com/wiki/Download#Windows

Compiler GCC 4.7.1: http://tdm-gcc.tdragon.net/download

Environment variable:

    + Right-click on "My Computer" and select "Properties".
    + Click Advanced -> Environment Variables.
    + In the box entitled "System Variables" scroll down to the line that says
    "Path" and double-click the entry.

    Scroll to the end of the string and at the end add them:

    > echo %Path%
    C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Go\bin;C:\Documents a
nd Settings\neo\go\bin;C:\MinGW\bin;C:\Program Files\Mercurial

    Add GOROOT and GOPATH:

    > echo %GOROOT%
    C:\Go\

    >echo %GOPATH%
    C:\Documents and Settings\neo\go

Note:

1. there is to restart Windows for that it expands the value at using %USERPROFILE%
2. Both %USERPROFILE% and %UserProfile% are being expanded to
"C:\WINDOWS\system32\config\systemprofile", at least in my system, Windows XP.
So I use the direct path in both Path and GOPATH to avoid this problem.

Dobrosław Żybort

unread,
Mar 8, 2013, 6:06:37 PM3/8/13
to golan...@googlegroups.com

With the current setup when I import ftm (or anything else) it says cannot find package and gocode dose not give code hinting or auto complete.
 

James Richardson

unread,
Mar 8, 2013, 6:29:21 PM3/8/13
to golan...@googlegroups.com
Just running through this now will let you know if it works.

James Richardson

unread,
Mar 8, 2013, 6:31:47 PM3/8/13
to golan...@googlegroups.com
Yes and checked it several times to make sure.

Thanks for the reply tho.

James Richardson

unread,
Mar 8, 2013, 7:06:53 PM3/8/13
to golan...@googlegroups.com
This didn't solve the problem just cause a few more problems now nothing is working.

as in with ftm.Printf("hello world") didn't work last time but if I just used print("hello world") that would put out to console now it's not and no errors either!

This is getting a bit old now never had it this hard to get something working. 
Any idea if they are going to make the install a bit more user friendly.

thanks for the suggestion's.

On Friday, 8 March 2013 23:06:26 UTC, Archos wrote:

Martin Schnabel

unread,
Mar 8, 2013, 7:42:53 PM3/8/13
to golan...@googlegroups.com
On 03/09/2013 01:06 AM, James Richardson wrote:
> This didn't solve the problem just cause a few more problems now nothing
> is working.
>
> as in with ftm.Printf("hello world") didn't work last time but if I just
> used print("hello world") that would put out to console now it's not and
> no errors either!

could it be that you want to use the fmt package and not ftm?
just checking because you used ftm as example twice.

James Richardson

unread,
Mar 8, 2013, 7:54:29 PM3/8/13
to golan...@googlegroups.com
Nicely spotted yes I was I will have to wait for a few more mins to test again as I am just going through the install again!

I hope you are correct and that is all it was!

James Richardson

unread,
Mar 8, 2013, 9:07:56 PM3/8/13
to golan...@googlegroups.com
Bit of an update I can import now as mb0 spotted it was a typo my bad.

but the gocode is not working like it should on the hello world if I type "fmt." the box pops up but only hint I get is for functions in the current file and nothing from fmt like Printf?

so it is working just not on anything outside of the file I am typing in?
 

Archos

unread,
Mar 8, 2013, 9:25:33 PM3/8/13
to golan...@googlegroups.com
Go to http://play.golang.org/
Copy that code in your text editor, save it, and run it using "go run file.go". The output should be the same than in that page when you click on RUN.

James Richardson

unread,
Mar 8, 2013, 9:46:28 PM3/8/13
to golan...@googlegroups.com
Just done it works tried the Concurrent computation of pi and output was as expected.

now the only thing that isn't working as it should is the gocode code hinting and auto complete?

It only gives me hinting for functions in the same document like if I type fmt. in the main function the hit is "main"(as in the main function) I get no hints about features in fmt or math like Printf? or any other imported file.

so I assume gocode is working just not 100%!

James Richardson

unread,
Mar 8, 2013, 10:11:55 PM3/8/13
to golan...@googlegroups.com
Will be back tomorrow as I just realised it 3am.

JussiJ

unread,
Mar 8, 2013, 10:15:04 PM3/8/13
to golan...@googlegroups.com
On Saturday, March 9, 2013 1:46:28 PM UTC+11, James Richardson wrote:

> so I assume gocode is working just not 100%!

This might be an issue with goclipse  and not so much an issue with gocode .

I added gocode support to the Zeus IDE and the last time I checked gocode was working extremely well.

Jussi
 

JussiJ

unread,
Mar 8, 2013, 10:20:50 PM3/8/13
to golan...@googlegroups.com

There is a Go Windows installer found here: https://code.google.com/p/go/downloads/list

That worked perfectly for me. 

Jussi

James Richardson

unread,
Mar 9, 2013, 8:49:34 AM3/9/13
to golan...@googlegroups.com
go is installed and working it's just gocode that is not working 100%

Jan Mercl

unread,
Mar 9, 2013, 8:59:27 AM3/9/13
to James Richardson, golang-nuts
On Sat, Mar 9, 2013 at 2:49 PM, James Richardson
<1985.james...@gmail.com> wrote:
> go is installed and working it's just gocode that is not working 100%

It might be the case that the culprit is not gocode (it works 100% for me here).

When you write `fmt.` and activate the completion - is there a `import
"fmt"` line in the source already? Because if not then gocode cannot
help you.

-j

James Richardson

unread,
Mar 9, 2013, 9:12:06 AM3/9/13
to golan...@googlegroups.com, James Richardson
yes I have imported and the code works so I know it has included the fmt package but the only suggestions I get are for functions created in the go file e.g.

if I create the helloworld.go

package main

import "fmt"

func main(){
fmt.Printf("Hello") (on this line if I type fmt. the only suggestion I get is main() )
}

and if I start typing func I get no suggestion to auto complete.

I have also tried using the gocode from the suggested link and the one that come with goclipse?

Nate Finch

unread,
Mar 9, 2013, 10:10:40 AM3/9/13
to James Richardson, golan...@googlegroups.com

For what it's worth,  I wouldn't use eclipse... It's way too heavyweight. Sublime Text 2 with GoSublime is my editor of choice,  it's a lot lighter weight than eclipse,  but still has text completion, syntax highlighting,  etc. You can run a free trial of ST2 for as long as you want,  it'll just bug you sometimes when you save.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

James Richardson

unread,
Mar 9, 2013, 11:01:04 AM3/9/13
to golan...@googlegroups.com, James Richardson
yeah i did look at sublime but with the install it says.

  1. Click the Preferences > Browse Packages… menu entry
  2. Browse up a folder and then into the Installed Packages folder 
  3. Download the testing version of Package Control.sublime-package and copy it into the Installed Packages directory
  4. Restart Sublime Text
The problem here is there is no installed packages folder?

James Richardson

unread,
Mar 9, 2013, 11:32:56 AM3/9/13
to golan...@googlegroups.com, James Richardson
it would appear that it is working fine without that just done the install tho I did put the suggested file into package control not installed packages?



On Saturday, 9 March 2013 15:10:40 UTC, Nate Finch wrote:

JussiJ

unread,
Mar 9, 2013, 8:58:46 PM3/9/13
to golan...@googlegroups.com, James Richardson
On Sunday, March 10, 2013 1:12:06 AM UTC+11, James Richardson wrote:

and if I start typing func I get no suggestion to auto complete.

I have also tried using the gocode from the suggested link and the one that come with goclipse?

I took your code:

    import "fmt"

    func main(){
        fmt
    }

and from inside Zeus tried getting gocode complete, but like you I didn't get any completion results.

So I then compiled that file inside Zeus and this was the compiler error generated:

    test.go:3:1: expected 'package', found 'import'

This is the reason the gocode was not auto-completing.

In my case by adding 'package main' to the top of the file the gocode was once again working as expected.
 
Jussi 

James Richardson

unread,
Mar 9, 2013, 10:19:59 PM3/9/13
to golan...@googlegroups.com, James Richardson
No that wasn't the problem for me that was just an example of me showing import and then typing fmt. I did have package main at the top in my code just didn't type it out here suppose I should have Copy/Pasted it all.

Thanks for all the help from everyone I am using GoSublime 2 as Nate suggested and it works nicely.

Sam Harwell

unread,
Mar 9, 2013, 10:45:47 PM3/9/13
to James Richardson, golan...@googlegroups.com

Hi James,

 

As an alternative, you might try playing with GoWorks for a bit. The code completion feature in GoWorks is very different from gocode (much faster and much more forgiving). We have a video to help you get started using GoWorks and showing various ways to make our code completion features save you time.

http://tunnelvisionlabs.com/products/demo/goworks

 

The code completion in GoWorks unfazed by the example code you provided, so you can work without problems and then address the compiler error (lack of a package clause) separately.

 

Thank you,

--

Sam Harwell

Owner, Lead Developer

http://tunnelvisionlabs.com

--

Dougx

unread,
Mar 10, 2013, 8:33:37 AM3/10/13
to golan...@googlegroups.com
For what it's worth I use eclipse all the time and have no issue with it what so ever, so I guess it's really just a preference thing really.

~
Doug.

James Richardson

unread,
Mar 10, 2013, 4:20:47 PM3/10/13
to golan...@googlegroups.com, James Richardson
Thanks for the info I may give it a try it sounds intresting. 
Reply all
Reply to author
Forward
0 new messages