Complete Computing Environment: Golang

Table of Contents

Programming in Goggle Go

(provide 'cce-golang)

I am … decidedly not a fan of Google's Go language, but I need to use it to make far more money than I deserve, so I use it.

export GOPATH=/home/rrix/go/
export PATH=/home/rrix/bin:$GOPATH/bin:$PATH
- name: golang and tools installed
  apt:
    state: installed
    name: "{{item}}"
  when: ansible_pkg_mgr == "apt"
  with_items:
  - golang-go
  - golang-1.10-doc

- name: golang and tools installed
  dnf:
    state: installed
    name: "{{item}}"
  when: ansible_pkg_mgr == "dnf"
  with_items:
  - golang-bin
  - golang-docs

- name: gocode etc installed
  shell:
    cmd: "go get {{item}}"
    creates: /home/rrix/go/bin/goflymake
  become: yes
  become_user: rrix
  with_items:
  - github.com/dougm/goflymake
  - golang.org/x/tools/cmd/goimports
  - golang.org/x/tools/cmd/...

I use goimports instead of gofmt, configure and enable it, as well as company-go for code completion in Golang.

(install-pkgs '(go-mode))

(setq gofmt-command "goimports")
(add-hook 'go-mode-hook (lambda ()
                           (add-hook 'before-save-hook 'gofmt-before-save nil t)))
(add-hook 'go-mode-hook (lambda ()
                          (set (make-local-variable 'company-backends) '(company-go))
                          (company-mode)))
(add-hook 'go-mode-hook (lambda ()
                          (aggressive-indent-mode -1)))
(add-hook 'go-mode-hook (lambda ()
                          (company-mode)
                          (go-eldoc-setup)))

Author: Ryan Rix

Created: 2018-07-09 Mon 14:48

Validate XHTML 1.0