 (add-to-list 'load-path (concat (getenv "GOPATH")  "/src/github.com/golang/lint/misc/emacs"))
 (require 'golint)
 
-;;Project Explorer
+;; Project Explorer.
 (require 'project-explorer)
 (global-set-key (kbd "M-e") 'project-explorer-toggle)
 

  (local-set-key (kbd "M-.") 'godef-jump))
(add-hook 'go-mode-hook 'go-mode-setup)

;;Custom Compile Command
(defun go-mode-setup ()
  (setq compile-command "go build -v && go test -v && go vet && golint && errcheck")
  (define-key (current-local-map) "\C-c\C-c" 'compile)

  (package-initialize))

(defvar my-packages
  '(;; Go stuff
    go-mode
    go-eldoc
    go-autocomplete

    ;; Markdown
    markdown-mode

    ;; Javascript
    json-mode

    ;; Env
    project-explorer
    smooth-scroll
    buffer-move
    window-number)
  "My packages!")

;; Fetch the list of packages available.
(unless package-archive-contents
  (package-refresh-contents))

;; Install the missing packages.
(dolist (package my-packages)
  (unless (package-installed-p package)
    (package-install package)))

;; Load Go-specific language syntax.
(defun go-mode-setup ()
  (go-eldoc-setup))

(add-hook 'go-mode-hook 'go-mode-setup)

;; Format before saving.
(defun go-mode-setup ()
  (go-eldoc-setup)
  (add-hook 'before-save-hook 'gofmt-before-save))
(add-hook 'go-mode-hook 'go-mode-setup)

;; Goimports.
(defun go-mode-setup ()
  (go-eldoc-setup)
  (setq gofmt-command "goimports")
  (add-hook 'before-save-hook 'gofmt-before-save))
(add-hook 'go-mode-hook 'go-mode-setup)

;; Godef, shows function definition when calling godef-jump.
(defun go-mode-setup ()
  (go-eldoc-setup)
  (setq gofmt-command "goimports")
