Search This Blog

Tuesday 15 December 2015

Golang Tips and Tricks


Installation of Go crypto/ssh module (Ubuntu 15.04)

 

go get -v code.google.com/p/go.crypto/ssh

code.google.com/p/go.crypto (download)
go: missing Mercurial command. See http://golang.org/s/gogetcmd
package code.google.com/p/go.crypto/ssh: exec: "hg": executable file not found in $PATH

This failure in downloading the crypto/ssh package is due to the fact the crypto/ssh repo was moved to golang.org/x/crypto/ssh.

go get -v  golang.org/x/crypto/ssh

Fetching https://golang.org/x/crypto/ssh?go-get=1
Parsing meta tags from https://golang.org/x/crypto/ssh?go-get=1 (status code 200)
...
...
# golang.org/x/crypto/ssh
/home/tamara/.gvm/pkgsets/go1.3.3/global/src/golang.org/x/crypto/ssh/keys.go:492: undefined: crypto.Signer

This error is fixed by upgrading Go to at least 1.4.

go get -v  golang.org/x/crypto/ssh

golang.org/x/crypto/curve25519
golang.org/x/crypto/ssh

Setting $GOPATH (golang workspace) when installing Go with gvm

 

Ubuntu comes with an obsolete Go version. We can use gvm, Go version manager, to install a higher Go version by following steps in the http://www.hostingadvice.com/how-to/install-golang-on-ubuntu/

Starting to use a particular Go version (gvm use go1.4.2) resets some of the Go environment variables:

go env

GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/tamara/.gvm/pkgsets/go1.4.2/global"
GORACE=""
GOROOT="/home/tamara/.gvm/gos/go1.4.2"
GOTOOLDIR="/home/tamara/.gvm/gos/go1.4.2/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"

gvm pkgset list

gvm go package sets (go1.4.2)

=>  global

gvm pkgset create tamarakaufler
gvm pkgset use tamarakaufler

=> Now using version go1.4.2@tamarakaufler
gvm pkgset list
gvm go package sets (go1.4.2)

    global
=>  tamarakaufler
 
gvm pkgenv tamarakaufler
opens the default editor for configuration of the 
project specific workspace. Edit the lines 12 
and 16 accordingly (bold parts)  

# line 12
export GOPATH; GOPATH="/home/tamara/.gvm/pkgsets/go1.4.2/tamarakaufler:$HOME/programming/go:$GOPATH"

# line 16
export PATH; PATH="/home/tamara/.gvm/pkgsets/go1.4.2/tamarakaufler/bin:${GVM_OVERLAY_PREFIX}/bin:$HOME/programming/go/bin:${PATH}"

No comments:

Post a Comment

Note: only a member of this blog may post a comment.