已经参照官方的golang层,安装了所有依赖
目前可以补全python的方法,但是golang无效
emacs 26.1
输入 gocode status输出如下:
gocode status ⬡ 8.3.0
Server's GOMAXPROCS == 8
Package cache contains 1 entries
Listing these entries:
name: unsafe (default alias: unsafe)
imports 4 declarations and 0 packages
this package stays in cache forever (built-in package)
Last edited file: /home/ft-arch/test.go (package: main)
Other files from the current package:
/home/ft-arch/test1.go
Listing declarations from files:
/home/ft-arch/test.go:
/home/ft-arch/test1.go:
加上我在github上提的issue吧
opened 02:17PM - 24 Jul 18 UTC
closed 05:35AM - 11 Sep 18 UTC
Go
Auto-completion
#### Description :octocat:
When i config go lang and auto-compltion and python … layers, then i try to
write go and python file. The completion work well with python but not work with golang.
#### Reproduction guide :beetle:
- Start Emacs
- C-x C-f some_go_file.go
- C-x C-f some_python.py
*Observed behaviour:* :eyes: :broken_heart:
e.g. when i write a python file,
```
import time
time.
```
after . there auto-complete some func and method
but when i write a go file
e.g.
```
package main
import "fmt"
func main () {
fmt.
}
```
nothing happend.
*Expected behaviour:* :heart: :smile:
I use arch and emacs26.1, i also add ```GOPATH``` to my .zshenv
here is my .zshenv
```
# golang
export GOPATH="$HOME/development/go/"
export PATH="$PATH:$HOME/development/go/bin"
export GOROOT="/usr/lib/go"
export GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
```
and here is my .zshrc
```
export GOPATH="$HOME/development/go/"
export PATH="$PATH:$HOME/development/go/bin"
export GOROOT="/usr/lib/go"
export GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
```
here is my .spacemacs:
```
dotspacemacs-configuration-layers
'(
go
python
;; ----------------------------------------------------------------
;; Example of useful layers you may want to use right away.
;; Uncomment some layer names and press <SPC f e R> (Vim style) or
;; <M-m f e R> (Emacs style) to install them.
;; ----------------------------------------------------------------
helm
auto-completion
better-defaults
emacs-lisp
git
markdown
;; org
......
(add-hook 'after-init-hook 'global-company-mode)
(add-hook 'go-mode-hook
(lambda ()
(set (make-local-variable 'auto-completion-backends) '(auto-completion-go))
(auto-completon-mode)))
......
;; auto completion layer config
(setq-default dotspacemacs-configuration-layers '(
(auto-completion :variables
auto-completion-return-key-behavior 'complete
auto-completion-tab-key-behavior 'cycle
auto-completion-complete-with-key-sequence '"jk"
auto-completion-complete-with-key-sequence-delay 0.1
auto-completion-private-snippets-directory nil)
))
(defun dotspacemacs/user-config ()
......
```
i also try remove
```
(add-hook 'after-init-hook 'global-company-mode)
(add-hook 'go-mode-hook
(lambda ()
(set (make-local-variable 'auto-completion-backends) '(auto-completion-go))
(auto-completon-mode)))
```
but it doesn't work
Thanks for your replay
已经解决,解决方案在5楼
试试lsp-go?貌似没人提PR。自己先加个用用吧。
非常感谢 嗯,我已经提了issue,还在讨论,结果我会贴出来的,现在最好的方法,也就是你说的了,加个私有层吧
已经解决,应该是安装gotools时网络不好,出现了莫名的bug。
解决方案如下:
1.卸载go
2.重新安装go
3.在全局代理下重新安装全部工具链(我是比较懒的,因为同时是vim党,直接通过vim-go,GOBINARYINSTALL搞定了)
4.enjoy it