## An autocompletion daemon for the Go programming language
**IMPORTANT: consider switching to https://github.com/mdempsky/gocode if you have problems starting with Go version 1.10, due to changes in binary packages architecture (introduction of package cache) I'm not going to adjust gocode for it for quite some time. There is a higher chance that fork under the given link will have some solution to the problem sooner or later.**
Gocode is a helper tool which is intended to be integrated with your source code editor, like vim, neovim and emacs. It provides several advanced capabilities, which currently includes:
- Context-sensitive autocompletion
It is called *daemon*, because it uses client/server architecture for caching purposes. In particular, it makes autocompletions very fast. Typical autocompletion time with warm cache is 30ms, which is barely noticeable.
Also watch the [demo screencast](http://nosmileface.ru/images/gocode-demo.swf).
![Gocode in vim](http://nosmileface.ru/images/gocode-screenshot.png)
![Gocode in emacs](http://nosmileface.ru/images/emacs-gocode.png)
### Setup
1. You should have a correctly installed Go compiler environment and your personal workspace ($GOPATH). If you have no idea what **$GOPATH** is, take a look [here](http://golang.org/doc/code.html). Please make sure that your **$GOPATH/bin** is available in your **$PATH**. This is important, because most editors assume that **gocode** binary is available in one of the directories, specified by your **$PATH** environment variable. Otherwise manually copy the **gocode** binary from **$GOPATH/bin** to a location which is part of your **$PATH** after getting it in step 2.
Do these steps only if you understand why you need to do them:
`export GOPATH=$HOME/goprojects`
`export PATH=$PATH:$GOPATH/bin`
2. Then you need to get the appropriate version of the gocode, for 6g/8g/5g compiler you can do this:
`go get -u github.com/nsf/gocode` (-u flag for "update")
Windows users should consider doing this instead:
`go get -u -ldflags -H=windowsgui github.com/nsf/gocode`
That way on the Windows OS gocode will be built as a GUI application and doing so solves hanging window issues with some of the editors.
3. Next steps are editor specific. See below.
### Vim setup
#### Vim manual installation
Note: As of go 1.5 there is no $GOROOT/misc/vim script. Suggested installation is via [vim-go plugin](https://github.com/fatih/vim-go).
In order to install vim scripts, you need to fulfill the following steps:
1. Install official Go vim scripts from **$GOROOT/misc/vim**. If you did that already, proceed to the step 2.
2. Install gocode vim scripts. Usually it's enough to do the following:
2.1. `vim/update.sh`
**update.sh** script does the following:
#!/bin/sh
mkdir -p "$HOME/.vim/autoload"
mkdir -p "$HOME/.vim/ftplugin/go"
cp "${0%/*}/autoload/gocomplete.vim" "$HOME/.vim/autoload"
cp "${0%/*}/ftplugin/go/gocomplete.vim" "$HOME/.vim/ftplugin/go"
2.2. Alternatively, you can create symlinks using symlink.sh script in order to avoid running update.sh after every gocode update.
**symlink.sh** script does the following:
#!/bin/sh
cd "${0%/*}"
ROOTDIR=`pwd`
mkdir -p "$HOME/.vim/autoload"
mkdir -p "$HOME/.vim/ftplugin/go"
ln -s "$ROOTDIR/autoload/gocomplete.vim" "$HOME/.vim/autoload/"
ln -s "$ROOTDIR/ftplugin/go/gocomplete.vim" "$HOME/.vim/ftplugin/go/"
3. Make sure vim has filetype plugin enabled. Simply add that to your **.vimrc**:
`filetype plugin on`
4. Autocompletion should work now. Use `<C-x><C-o>` for autocompletion (omnifunc autocompletion).
#### Using Vundle in Vim
Add the following line to your **.vimrc**:
`Plugin 'nsf/gocode', {'rtp': 'vim/'}`
And then update your packages by running `:PluginInstall`.
#### Using vim-plug in Vim
Add the following line to your **.vimrc**:
`Plug 'nsf/gocode', { 'rtp': 'vim', 'do': '~/.vim/plugged/gocode/vim/symlink.sh' }`
And then update your packages by running `:PlugInstall`.
#### Other
Alternatively take a look at the vundle/pathogen friendly repo: https://github.com/Blackrush/vim-gocode.
### Neovim setup
#### Neovim manual installation
Neovim users should also follow `Vim manual installation`, except that you should goto `gocode/nvim` in step 2, and remember that, the Neovim configuration file is `~/.config/nvim/init.vim`.
#### Using Vundle in Neovim
Add the following line to your **init.vim**:
`Plugin 'nsf/gocode', {'rtp': 'nvim/'}`
And then update your packages by running `:PluginInstall`.
#### Using vim-plug in Neovim
Add the following line to your **init.vim**:
`Plug 'nsf/gocode', { 'rtp': 'nvim', 'do': '~/.config/nvim/plugged/gocode/nvim/symlink.sh' }`
And then update your packages by running `:PlugInstall`.
### Emacs setup
In order to install emacs script, you need to fulfill the following steps:
1. Install [auto-complete-mode](http://www.emacswiki.org/emacs/AutoComplete)
2. Copy **emacs/go-autocomplete.el** file from the gocode source distribution to a directory which is in your 'load-path' in emacs.
3. Add these lines to your **.emacs**:
(require 'go-autocomplete)
(require 'auto-complete-config)
(ac-config-default)
Also, there is an alternative plugin for emacs using company-mode. See `emacs-company/README` for installation instructions.
If you're a MacOSX user, you may find that script useful: https://github.com/purcell/exec-path-from-shell. It helps you with setting up the right environment variables as Go and gocode require it. By default it pulls the PATH, but don't forget to add the GOPATH as well, e.g.:
```
(when (memq window-system '(mac ns))
(exec-path-from-shell-initialize)
(exec-path-from-shell-copy-env "GOPATH"))
```
### Options
You can change all available options using `gocode set` command. The config file uses json format and is usually stored somewhere in **~/.config/gocode** directory. On windows it's stored in the appropriate AppData folder. It's suggested to avoid modifying config file manually, do that using the `gocode set` command.
`gocode set` lists all options and their values.
`gocode set <option>` shows the value of that *option*.
`gocode set <option> <value>` sets the new *value* for that *option*.
- *propose-builtins*
A boolean option. If **true**, gocode will add built-in types, functions and constants to autocompletion proposals. Default: **false**.
- *lib-path*
A string option. Allows you to add search paths for packages. By default, gocode only searches **$GOPATH/pkg/$GOOS_$GOARCH** and **$GOROOT/pkg/$GOOS_$GOARCH** in terms of previously existed environment variables. Also you can specify multiple paths using ':' (colon) as a separator (on Windows use semicolon ';'). The paths specified by *lib-path* are prepended to the default ones.
- *autobuild*
A boolean option. If **true**, gocode will try to automatically build out-of-date packages when their source files are modified, in order to obtain the freshest autocomplete results for them. This feature is experimental. Default: **false**.
- *force-debug-output*
A string option. If is not empty, gocode will forcefully redirect the logging into that file. Also forces enabling of the debug mode on the server side. Default: "" (empty).
- *package-lookup-mode*
A string option. If **go**, use standard Go package lookup rules. If **gb**, use gb-specific lookup rules. See https://github.com/constabulary/gb for details. Default: **go**.
- *close-timeout*
An integer option. If there have been no completion requests after this number of seconds, the gocode process will terminate. Defaults to 1800 (30 minutes).
- *unimported-packages*
A boolean option. If set to true, gocode will try to import certain known pack
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
go插件包下载 (1456个子文件)
00754ed2d7fa0914da405bab5e6fb4d130dbf4 144B
01c4e24450cd59b96496cbf5fbf2de7347a617 110B
06c34d5dc77751b7294eb7adc89ba766e4a673 133B
088f637661c367fafb98e0d0ed03041d1ff29a 145B
09c1a1f35f5e08c8d0aa868952639de16c5045 1KB
09e4426dd05528daca4f34741e5de018810c50 190B
0c1cbbe41fcdc46db13a200824c819fb02ad25 114B
cursor.104 0B
cursor.105 0B
cursor.105 0B
cursor.109 0B
cursor.109 0B
cursor.114 0B
cursor.120 0B
cursor.122 0B
cursor.126 0B
cursor.126 0B
cursor.129 0B
cursor.130 0B
cursor.1348 0B
cursor.138 0B
cursor.139 0B
cursor.140 0B
cursor.141 0B
14944646484d5530b877d9caf03e3fea6373f9 230B
14d6f50d38bbd47acf9695db0260e30015de06 175B
cursor.164 0B
cursor.168 0B
cursor.174 0B
cursor.182 0B
cursor.1835 0B
1900801f9858a61dce3a77da6685bd2c50adb5 170B
cursor.191 0B
198b4128c45d605e00c434ed6628fcbaa00d05 183B
199672d227937e95eeccc07245e310f5074cf3 852B
1d2d5038d953678a59243bea20b47519d79d83 117B
1dca2df8832cbb00fdd55cf889fd59f6605852 149B
20b019bb3a22bea246f25a181305d91c466a7c 118B
cursor.211 0B
cursor.215 0B
cursor.229 0B
23d6eb2584567abb5bcbc7720bbf706c9b747f 177B
cursor.247 0B
251eb2311dd46983ba44f8d27f0784a1c6a769 1KB
cursor.286 0B
2914d8d66213845c4e80a39cd28b4078c132ca 840B
2d10b4f1aaad3ad40c92b14d035dfc48c576bf 85B
2f570f1aeb64a2fbd25b826fceabc5550e7bf5 473B
300f04b4028e945a0243244f2b95e467ba6564 678B
30bffc4a457198ac72167afeb7d76a7ea6a6be 52B
cursor.327 0B
3384bf1b1e585eed05699851b7be04c8bf12bd 179B
353100bb825fdea22d5e983ea30ae5cfdb9841 565B
cursor.355 0B
cursor.359 0B
36091585b7f0715b24583c2dfc3ad5dc0b9ef5 176B
39d75d69c1b4655ef9def8f6798b497dfff558 155B
39dc571ee7009bd467e510ce26411ab0a5416c 167B
3b2206bbedd91eb32d5e38bfa330608817821d 836B
3b8b86b87fb96e47f302b2f42336515d1286b5 1KB
3db590f5c162b7e48fd9715647b9149a32c2d5 161B
3f8d972f47ba2120a39a82eddea7cc0b989d9a 1KB
4279f2702564a26a0ef884455ba66409b1a65a 573B
4294ada4c55d3841c28c3b43aa62c0820166f0 171B
42c62d674ce1e5392092e7e452c49d14643af1 588B
42c9cb6995b408696647a0e182808d1649e37c 150B
cursor.43 2B
cursor.44 0B
44f2c400e2a5d16da4c438d1015187133b1221 734B
cursor.45 0B
cursor.47 0B
472057c5f0701dba689345673bff2522b0f7cb 873B
4a69903fc270d8911bc0f2a07502975dfdf857 56B
4a9246e4f37e6e32e59a288aeaf12cf9e1e3df 151B
4f2ac40a2c91ae6c5ae68cf8cfb9b315c3879d 253B
505ef666d1ecfde4067ae7a0037543e9fed3e9 166B
cursor.51 0B
cursor.53 0B
cursor.53 0B
cursor.53 0B
5340a0803eafec03906da3e6ad50076af0b7f9 247B
cursor.552 0B
cursor.56 0B
572f92966f79296eded4f7f8da8140153f0db7 267B
cursor.58 0B
5b8908a0a4099adbbc43a932255869124c5c01 257B
5d2d6990c0b9d7e3f0791a5498354ed05888f7 150B
5dfefa0d235b7ad4cc62f3cadbccb3ea0db81f 204B
cursor.61 0B
617677d4af1b78b80f160a76b4b2e2d9379c39 483B
cursor.62 0B
630c48bd3db9043e7ea466d73c3fababe0ff08 120B
63c3bcb1d759cd135b683f7756e57d30854f99 120B
645b9b01f34b0952e7539425c29d3dbc843a1d 647B
cursor.65 0B
6581862bf907ee45aaa25de241009fb7ddd949 178B
66619ca3c1313c1857babf9470d08e91d46ebb 666B
cursor.67 0B
67ae9c2ce27f79392edbc37bb1d3aed4d6ddad 340B
6acfba39ebbc3352a16df655bb7a132219eea4 264B
共 1456 条
- 1
- 2
- 3
- 4
- 5
- 6
- 15
资源评论
- 13759179822019-08-29下载后,看到的是go文件,并没有exe文件,不是想要的
- Brain_csdn2018-06-06下载后不知道到哪里了
a1035127752
- 粉丝: 1
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于51单片机的自动浇花设计论文
- 客服机器人需要的数据集,包括order、ware、user,测试集和开发集
- 用0到9生成十位数的所有排列组合(java代码).docx
- 模仿魔慢相机的人脸监测选择ios组件
- STM32F103C8T6模拟IIC控制4针0.96寸OLED显示屏已测
- Chromeextent_paly.zip
- 【2023年全国职业技能大赛“信息安全与评估”赛项】任务4-Linux内存取证WP+靶场环境
- 基于51单片机数字电压表的设计(PCB+原理图+仿真+论文+代码)
- open62541在window10 VS2019编译完成的源码
- 新闻文章自动新闻采集系统-webapps.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功