Skip to content
This repository has been archived by the owner on Feb 27, 2020. It is now read-only.

Golang Box #33

Closed
genedna opened this issue Feb 24, 2014 · 14 comments
Closed

Golang Box #33

genedna opened this issue Feb 24, 2014 · 14 comments

Comments

@genedna
Copy link

genedna commented Feb 24, 2014

I am a gopher. I really like codio, so I need golang box for development.

@ksimuk
Copy link
Member

ksimuk commented Feb 24, 2014

try :
go-lang (1.2) Go is an open source programming language that makes it easy to build simple,
reliable, and efficient software.

parts install go-lang

@fmay fmay closed this as completed Feb 24, 2014
@genedna
Copy link
Author

genedna commented Feb 24, 2014

I installed successfully, but how could I set GOPATH and where point to?
I need a golang template when I create a project in Codio.

@fmay
Copy link

fmay commented Feb 24, 2014

If you send us a template, we'll use that as a start and add it to templates. We are not really experienced Go users, so if you tell us what you want, we'll do our best to add it quickly.

@MaximKraev can you help with the GOPATH question?

@fmay fmay reopened this Feb 24, 2014
@genedna
Copy link
Author

genedna commented Feb 24, 2014

I don't know the template of Codio. If the Codio box base the Docker, it's just a Docker within Golang like https://index.docker.io/u/mischief/docker-golang.

@fmay
Copy link

fmay commented Feb 24, 2014

@genedna is now clear what you mean by template. @MaximKraev can we set it up as suggested by @genedna ?

@ksimuk
Copy link
Member

ksimuk commented Feb 24, 2014

our docker container don't have golang preinstalled, parts packages are installed into a user home directory, go lang is located in ~/.parts/packages/go-lang/1.2/
please also do not forget to close and open a terminal, it is the small notice after install. I will work to make it more visible

codio@6d719e70fb09:~/workspace$ parts install go-lang                                                                          
=> Downloading http://parts.codio.com/box-codio-v1/go-lang-1.2-binary.tar.gz...                                                
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                                
                                 Dload  Upload   Total   Spent    Left  Speed                                                  
100    41  100    41    0     0   2163      0 --:--:-- --:--:-- --:--:--  2733                                                 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                                
                                 Dload  Upload   Total   Spent    Left  Speed                                                  
100 53.5M  100 53.5M    0     0  45.6M      0  0:00:01  0:00:01 --:--:-- 45.7M                                                 
=> Extracting archive...                                                                                                       
=> Installing...                                                                                                               
=> Symlinking...                                                                                                               
=> Installed go-lang 1.2                                                                                                       

Close and open terminal to have go-lang working after the install.                                                             

codio@6d719e70fb09:~/workspace$                                                                                                

codio@6d719e70fb09:~/workspace$ go                                                                                             
Go is a tool for managing Go source code.                                                                                      

Usage:                                                                                                                         

        go command [arguments]                                                                                                 

The commands are:                                                                                                              

    build       compile packages and dependencies                                                                              
    clean       remove object files                                                                                            
    env         print Go environment information                                                                               
    fix         run go tool fix on packages                                                                                    
    fmt         run gofmt on package sources                                                                                   
    get         download and install packages and dependencies                                                                 
    install     compile and install packages and dependencies                                                                  
    list        list packages                                                                                                  
    run         compile and run Go program                                                                                     
    test        test packages                                                                                                  
    tool        run specified go tool                                                                                          
    version     print Go version                                                                                               
    vet         run go tool vet on packages                                                                                    

Use "go help [command]" for more information about a command.                                                                  

Additional help topics:                                                                                                        

    c           calling between Go and C                                                                                       
    gopath      GOPATH environment variable                                                                                    
    importpath  import path syntax                                                                                             
    packages    description of package lists                                                                                   
    testflag    description of testing flags                                                                                   
    testfunc    description of testing functions                                                                               

Use "go help [topic]" for more information about that topic.                                                                   

codio@6d719e70fb09:~/workspace$ go run test.go                                                                                 
Hello, 世界                                                                                                                      
codio@6d719e70fb09:~/workspace$ cat test.go                                                                                    
// You can edit this code!                                                                                                     
// Click here and start typing.                                                                                                
package main                                                                                                                   

import "fmt"                                                                                                                   

func main() {                                                                                                                  
        fmt.Println("Hello, 世界")                                                                                               
}codio@6d719e70fb09:~/workspace$                                                                                               

@fmay
Copy link

fmay commented Feb 24, 2014

@genedna if you are all ok with this, I will close the issue out.

@genedna
Copy link
Author

genedna commented Feb 24, 2014

@MaximKraev When you get the 3rd package, you will got

codio@369c78af72c4:~/workspace$ go get github.com/elazarl/goproxy                                                                                                     
package github.com/elazarl/goproxy: cannot download, $GOPATH not set. For more details see: go help gopath 

If I set $GOPATH, I write it to .profile or .bash_profile ?

@ksimuk
Copy link
Member

ksimuk commented Feb 24, 2014

ok, now I understand the issue, it is fixed
do

parts uninstall go-lang
parts update
parts install go-lang

and restart terminal

@fabioxgn
Copy link

@MaximKraev I think this doesn't solve the issue.

The GOPATH must have a certain directory structure, as explained here: http://golang.org/doc/code.html#Workspaces

I tried installing go, and my environment now is like this:

codio@mowana-barful:~/workspace$ echo $GOPATH                                                                                                                                                                   
/home/codio/.parts/packages/go-lang/1.2/gopath                                                                                                                                                                   
codio@mowana-barful:~/workspace$ go get
go install: no install location for directory /home/codio/workspace outside GOPATH

For go to work property, the project in my case, should be in a folder like this:

 ~/workspace/src/github.com/fabioxgn/go-bot

And the GOPATH should point to the ~/workspace, which must have the src folder.

So the structure should be:

$GOPATH/src/site/user/repository

@mikeroosa
Copy link

Were you able to get this working @fabioxgn ?

I installed go-lang and run into the same problems as you.

I set $GOPATH to ~/workspace/src/github.com/mikeroosa/hello from the command line but the command 'go install' gives me the GOPATH error as well.

@fabioxgn
Copy link

@mikeroosa to be honest didn't tried again. Will try it when I have the chance.

@mikeroosa
Copy link

@fabioxgn Actually, I did get it working temporarily. I typed this at the terminal

export GOPATH=~/workspace

How do I add that so it stays when I close the terminal and re-open?

@fabioxgn
Copy link

@mikeroosa To persist the GOPATH you just have to add it to ~/.bash_profile

I configured a new box from scratch and it worked great.

Step by step what I did was:

  • Create a new empty project
  • Execute on the terminal: parts install go-lang
  • Edited ~/.bash_profile and added: export GOPATH="$HOME/workspace"
  • Restarted terminal and go get, go build, etc are all working

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants