From d16214faa3862a35a52186659facdbc716170ddb Mon Sep 17 00:00:00 2001
From: Doug MacEachern <dougm@vmware.com>
Date: Tue, 3 Jun 2014 18:03:05 -0700
Subject: [PATCH] Add Go module

---
 modules/prelude-go.el     | 88 +++++++++++++++++++++++++++++++++++++++
 sample/prelude-modules.el |  1 +
 2 files changed, 89 insertions(+)
 create mode 100644 modules/prelude-go.el

diff --git a/modules/prelude-go.el b/modules/prelude-go.el
new file mode 100644
index 0000000..08a0450
--- /dev/null
+++ b/modules/prelude-go.el
@@ -0,0 +1,88 @@
+;;; prelude-go.el --- Emacs Prelude: Go programming support.
+;;
+;; Author: Doug MacEachern
+;; Version: 1.0.0
+;; Keywords: convenience go
+
+;; This file is not part of GNU Emacs.
+
+;;; Commentary:
+
+;; Prelude configuration for Go
+
+;;; License:
+
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License
+;; as published by the Free Software Foundation; either version 3
+;; of the License, or (at your option) any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
+
+;;; Code:
+
+(require 'prelude-programming)
+
+(prelude-require-packages '(go-mode
+                            company-go
+                            go-eldoc
+                            go-projectile
+                            gotest))
+
+(require 'go-projectile)
+
+;; Ignore go test -c output files
+(add-to-list 'completion-ignored-extensions ".test")
+
+(eval-after-load 'go-mode
+  '(progn
+     (defun prelude-go-mode-defaults ()
+       ;; Default key bindings for gotest.el
+       (let ((map go-mode-map))
+         (define-key map (kbd "C-c a") 'go-test-current-project) ;; current package, really
+         (define-key map (kbd "C-c m") 'go-test-current-file)
+         (define-key map (kbd "C-c .") 'go-test-current-test)
+         (define-key map (kbd "C-c b") 'go-run))
+
+       ;; Prefer goimports to gofmt if installed
+       (let ((goimports (executable-find "goimports")))
+         (when goimports
+           (setq gofmt-command goimports)))
+
+       ;; gofmt on save
+       (add-hook 'before-save-hook 'gofmt-before-save nil t)
+
+       ;; stop whitespace being highlighted
+       (whitespace-toggle-options '(tabs))
+
+       ;; Company mode settings
+       (set (make-local-variable 'company-backends) '(company-go))
+
+       ;; El-doc for Go
+       (go-eldoc-setup)
+
+       ;; CamelCase aware editing operations
+       (subword-mode +1))
+
+     (setq prelude-go-mode-hook 'prelude-go-mode-defaults)
+
+     (add-hook 'go-mode-hook (lambda ()
+                               (run-hooks 'prelude-go-mode-hook)))
+
+     ;; Enable go-oracle-mode if available
+     (let ((oracle (executable-find "oracle")))
+       (when oracle
+         (setq go-oracle-command oracle)
+         (autoload 'go-oracle-mode "oracle")
+         (add-hook 'go-mode-hook 'go-oracle-mode)))))
+
+(provide 'prelude-go)
+;;; prelude-go.el ends here
diff --git a/sample/prelude-modules.el b/sample/prelude-modules.el
index 1e69864..0fa7fa4 100644
--- a/sample/prelude-modules.el
+++ b/sample/prelude-modules.el
@@ -17,6 +17,7 @@
 ;; (require 'prelude-css)
 (require 'prelude-emacs-lisp)
 ;; (require 'prelude-erlang)
+;; (require 'prelude-go)
 ;; (require 'prelude-haskell)
 (require 'prelude-js)
 ;; (require 'prelude-latex)