search

Home  >  Q&A  >  body text

golang - mac configuration gocode + vim automatic completion

Before, it was very convenient to use gocode+vim to write go under Linux. After switching to mac, no matter how I configured it, it was not successful, and I couldn’t achieve it step by step according to the author’s method. Can anyone who has done the same thing help me? Take a look, I wrote down my detailed configuration process.

method one:

  1. First download the max osx package through the golang official website http://code.google.com/p/go/downloads... It is installed by default under the /usr/local/go directory
  2. Follow the steps on the gocode official website https://github.com/nsf/gocode and add /usr/local/go/bin to PATH
  3. Finally, when using ctrl+c ctrl+o in the code, there is no automatic prompt

Method Two:
Later, I found a relatively comprehensive setting through Google.
https://github.com/astaxie/build-web-... There are many configurations of commonly used tools. After vim is configured, the situation is still the same.

My current system variables:

ajian@localhost:/usr/local/go $go env
warning: GOPATH set to GOROOT (/usr/local/go) has no effect
GOARCH="amd64"
GOBIN="/usr/local/go/bin"
GOCHAR="6"
GOEXE=""
GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread -fno-common"
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/usr/local/go"
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
CGO_ENABLED="1"
ajian@localhost:/usr/local/go $gocode set
propose-builtins true
lib-path "/usr/local/go/pkg/darwin_amd64/"

My vim configuration

ajian@localhost:~ $cat .vimrc
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" go 配置
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set shiftwidth=4
set expandtab
set tabstop=4
set softtabstop=4
set completeopt=longest,menu

filetype plugin indent on
syntax on

Maybe I don’t understand how gocode works. How to debug it? No clue now.

世界只因有你世界只因有你2780 days ago1020

reply all(3)I'll reply

  • 漂亮男人

    漂亮男人2017-05-16 16:44:05

    https://bitbucket.org/reckhou/myvim
    This is my VIM configuration, you can download it and try it out, it’s for MAC

    reply
    0
  • 世界只因有你

    世界只因有你2017-05-16 16:44:05

    It’s better to use LiteIDE. Debugging is also very convenient

    reply
    0
  • ringa_lee

    ringa_lee2017-05-16 16:44:05

    What does gocode -s output after gocode close?

    reply
    0
  • Cancelreply