Golang

From campisano.org
Jump to navigation Jump to search

Golang

Install

Using system packages

  • just a package:
## from Debian STABLE:
$ sudo apt-get install golang # Stable package
## or Debian BACKPORT:
$ sudo apt-get -t stretch-backports install golang
## to DEBUG, install also gdb:
$ sudo apt-get install gdb
  • and setup your user environment (you can put the follow in ~/.profile)
$ export GOPATH=${HOME}/go
$ export PATH=${PATH}:${GOPATH}/bin

Using golang binaries

  • to use last version, in this example 1.11.2
$ su -
$ apt-get autoremove --purge golang*
$ export VER_NAME=go1.11.2.linux-amd64
$ cd /home/shared/opt/software/
$ wget https://dl.google.com/go/${VER_NAME}.tar.gz
$ tar -xzf ${VER_NAME}.tar.gz
$ rm -f ${VER_NAME}.tar.gz
$ mv go ${VER_NAME}
$ ln -s ${VER_NAME} go
  • and setup your user environment (you can put the follow in ~/.profile)
$ export GOROOT="/home/shared/opt/software/go";
$ export GOPATH="${HOME}/go";
$ export PATH="${PATH}:${GOROOT}/bin:${GOPATH}/bin";

Test

$ mkdir -p $HOME/go/src/hello
$ cd $HOME/go/src/hello
$ cat > hello.go <<EOF
package main
import "fmt"
func main() {
fmt.Printf("hello, world\n")
}
EOF
$ go build
$ ./hello
hello, world
$ go install
$ hello
hello, world
$ type -p hello
/home/user/go/bin/hello

Troubles

In case of dependencies problems, e.g.

go: verifying github.com/labstack/echo@v3.3.5+incompatible: checksum mismatch

clean the checksum file:

rm go.sum
go clean -modcache

Source: go/issues/29281

Compile liteide IDE for Go

## Install Qt5
$ sudo apt-get install qt5-default
$ git clone https://github.com/visualfc/liteide.git
$ cd liteide/build
$ ./update_pkg.sh
$ ./build_linux_qt5.sh
$ ./deploy_linux_x64_qt5.sh
$ cat ./liteide/README.md | grep 'Version:'
$ sudo mv liteide /home/shared/opt/software/liteide_X33.4