Coder Social home page Coder Social logo

Golang Box about boxparts HOT 14 CLOSED

codio avatar codio commented on August 19, 2024
Golang Box

from boxparts.

Comments (14)

ksimuk avatar ksimuk commented on August 19, 2024

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

from boxparts.

genedna avatar genedna commented on August 19, 2024

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.

from boxparts.

fmay avatar fmay commented on August 19, 2024

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?

from boxparts.

genedna avatar genedna commented on August 19, 2024

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.

from boxparts.

fmay avatar fmay commented on August 19, 2024

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

from boxparts.

ksimuk avatar ksimuk commented on August 19, 2024

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$                                                                                               

from boxparts.

fmay avatar fmay commented on August 19, 2024

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

from boxparts.

genedna avatar genedna commented on August 19, 2024

@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 ?

from boxparts.

ksimuk avatar ksimuk commented on August 19, 2024

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

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

and restart terminal

from boxparts.

fabioxgn avatar fabioxgn commented on August 19, 2024

@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

from boxparts.

mikeroosa avatar mikeroosa commented on August 19, 2024

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.

from boxparts.

fabioxgn avatar fabioxgn commented on August 19, 2024

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

from boxparts.

mikeroosa avatar mikeroosa commented on August 19, 2024

@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?

from boxparts.

fabioxgn avatar fabioxgn commented on August 19, 2024

@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

from boxparts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.