(defun maple/go-packages-function()
"Return a list of all Go packages, using `gopkgs'."
(sort (process-lines "gopkgs") #'string<))
(setq go-packages-function 'maple/go-packages-function)
(defun maple/go-packages-function()
"Return a list of all Go packages, using `gopkgs'."
(sort (process-lines "gopkgs") #'string<))
(with-eval-after-load 'async
(add-hook 'go-mode-hook
(lambda() (async-start (lambda() (process-lines "gopkgs")) 'ignore))))
(setq go-packages-function 'maple/go-packages-function)
还可以异步调用后再缓存一下
(defun maple/go-packages-function()
"Return a list of all Go packages, using `gopkgs'."
(or maple/go-packages-list
(sort (process-lines "gopkgs") #'string<)))
(defvar maple/go-packages-list nil)
(with-eval-after-load 'async
(add-hook 'go-mode-hook
(lambda()
(async-start
(lambda()
(process-lines "gopkgs"))
(lambda(results)
(setq maple/go-packages-list (sort results#'string<)))))))
(setq go-packages-function 'maple/go-packages-function)