From campisano.org
Jump to navigation Jump to search



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.11
su -
apt-get autoremove --purge golang*
export VER_NAME=go1.11.11.linux-amd64      # Edit it when needed
cd /home/shared/opt/software/              # Edit it when needed
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
# optionally
chown -R root:users "${VER_NAME}"
find "${VER_NAME}" -type d -exec chmod u+rwx,g+rx,o-rwx {} \;
find "${VER_NAME}" -type f -exec chmod u+rw,g+rx,o-rwx {} \;
  • and setup your user environment (you can put the follow in ~/.profile)
export GOROOT="/home/shared/opt/software/go";      # Edit it when needed
export GOPATH="${HOME}/go";
export PATH="${PATH}:${GOROOT}/bin:${GOPATH}/bin";


mkdir -p "$HOME/tmp"
cd "$HOME/tmp"
cat > hello.go <<EOF
package main
import "fmt"
func main() {
fmt.Printf("hello, world\n")
go build
# hello, world


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



  • NOTE, the project is outdated

1) add goclipse plugin from http://goclipse.github.io/releases/

2) configure and install gocode, guru, godef tools

go get -u github.com/nsf/gocode
go get -u golang.org/x/tools/cmd/guru
go get -u github.com/rogpeppe/godef

3) configure build target using a Makefile, and run it from project_folder->right_click->build

make -C ${project_loc} debug

4) add a simple Makefile, like

    go build -v -gcflags=all="-N -l" ./cmd/YOUR_PACKAGE


  • Compile
## Install Qt5
sudo apt-get install qt5-default
wget -c https://github.com/visualfc/liteide/archive/x36.zip
unzip x36.zip
rm -f x36.zip 
cd liteide-x36/build/
ls liteide
su -c 'mv liteide /home/shared/opt/software/liteide_X36'
cd ../../
rm -rf liteide-x36/

GoWorks (NetBeans)



;; from https://github.com/dominikh/go-mode.el
(use-package go-mode
  :ensure t
  (autoload 'go-mode "go-mode" nil t)
  (add-to-list 'auto-mode-alist '("\\.go\\'" . go-mode))

;; from https://github.com/mdempsky/gocode/tree/master/emacs-company
;; remember to install gocode with
;;   go get -u github.com/mdempsky/gocode
(use-package company-go
  :ensure t
  (add-hook 'go-mode-hook
              (set (make-local-variable 'company-backends) '(company-go))

;; from https://github.com/benma/go-dlv.el/blob/master/go-dlv.el
;;      http://tleyden.github.io/blog/2014/05/22/
;;                               configure-emacs-as-a-go-editor-from-scratch/
;; remember to install dlv with
;;   go get -u github.com/derekparker/delve/cmd/dlv
(use-package go-dlv
  :ensure t

;; defining a custom layout for DLV
;; from http://www.campisano.org/wiki/en/Emacs
(defun fun_set-dlv-layout(var_editing_buffer)
  ;; (defvar-local var_source_window (selected-window))
  ;; (defvar-local var_debugging_window                     ; bottom
  ;;   (split-window var_source_window (floor(* 0.66 (window-body-height)))
  ;;                 'below))

  ;; (set-window-dedicated-p var_debugging_window t)
  ;; (select-window var_source_window)
  (set-window-buffer var_source_window var_editing_buffer)

;; (defvar global-config-editing)
(global-set-key (kbd "C-c g")
                (lambda() (interactive)
                  ;; (setq global-config-editing (current-window-configuration))
                  (setq var_editing_buffer (window-buffer (selected-window)))
                  ;; (dlv (concat "debug " (buffer-file-name)))
                  (fun_set-dlv-layout var_editing_buffer)
                  ;; (set-window-configuration global-config-editing)