         (setq pos (1+ pos))))
     (substring-no-properties str 0 pos)))
 
+; Uses meta as-is if annotation alignment is enabled. Otherwise removes first
+; two words from the meta, which are usually the class and the name of the
+; entity, the rest is the function signature or type. That's how annotations are
+; supposed to be used.
+(defun company-go--extract-annotation (meta)
+  "Extract annotation from META."
+  (if company-tooltip-align-annotations
+      meta
+    (save-match-data
+      (and (string-match "\\w+ \\w+\\(.+\\)" meta)
+           (match-string 1 meta)))))
+
 ;;;###autoload
 (defun company-go (command &optional arg &rest ignored)
   (case command

(defun company-go--invoke-autocomplete ()
  (let ((temp-buffer (generate-new-buffer "*gocode*")))
    (prog2
	(call-process-region (point-min)
			     (point-max)
			     company-go-gocode-command
			     nil
			     temp-buffer
			     nil
			     "-f=csv"
			     "autocomplete"
			     (or (buffer-file-name) "")
			     (concat "c" (int-to-string (- (point) 1))))
	(with-current-buffer temp-buffer (buffer-string))
      (kill-buffer temp-buffer))))

(defun company-go--format-meta (candidate)
  (let ((class (nth 0 candidate))
	(name (nth 1 candidate))
	(type (nth 2 candidate)))
    (setq type (if (string-prefix-p "func" type)
		   (substring type 4 nil)
		 (concat " " type)))
    (concat class " " name type)))

(defun company-go--get-candidates (strings)
  (mapcar (lambda (str)
	    (let ((candidate (split-string str ",,")))
	      (propertize (nth 1 candidate) 'meta (company-go--format-meta candidate)))) strings))

(defun company-go--candidates ()
  (company-go--get-candidates (split-string (company-go--invoke-autocomplete) "\n" t)))

            (goto-char point)
            (company-go--godef-jump point)))
      (ignore-errors
        (with-current-buffer temp-buffer
          (set-buffer-modified-p nil))
        (kill-buffer temp-buffer)
        (delete-file temp)))))

