Below is my emacs init file that relates to Go. I'm trying to use company mode to auto completes Go.
;;===================================================
; Golang related configuration
;;===================================================
(defun my-go-mode-hook ()
; Add go-guru
(require 'go-guru)
(require 'company)
(require 'company-go)
; Use goimports instead of go-fmt
(setq gofmt-command "goimports")
; Call Gofmt before saving
(add-hook 'before-save-hook 'gofmt-before-save)
; Customize compile command to run go build
(if (not (string-match "go" compile-command))
(set (make-local-variable 'compile-command)
;"go build -v && go test -v && go vet"))
"go run"))
; Godef jump key binding
(local-set-key (kbd "M-.") 'godef-jump))
(add-hook 'go-mode-hook 'my-go-mode-hook)
; Highlight identifiers in Golang by default
(add-hook 'go-mode-hook #'go-guru-hl-identifier-mode)
However, it seems that the company mode can only completes words that have been used in the buffer. See below screen shot.
What I want is to complete Go's builtin functions, like fmt.Fprintln
. It seems company mode can't do that. See below screen shot.
I want to confirm, is it true? Can emacs auto completes Go's builtin functions? Are there any example emacs init files that I can use as a reference? Thanks in advance.
Update
Confirmed I installed gocode.
I've cleared my init.el and only contains the minimal code to do the completion, but it still not work (emacs restarted).