<p>The autocompletion works wonderfully for the standard library and the package I'm currently working in, but fails when I import custom packages. Has anyone discovered a way to get the autocompletion working with custom packages? I have a tags file (generated by gotags) in the corresponding custom package.</p>
<hr/>**评论:**<br/><br/>mgutz: <pre><p>My guess is it uses gocode for autocompletion. I experience the same problems in Vim now and then, usually with sub packages that I've modified.</p>
<p>You can run gocode in server mode from the terminal</p>
<p><code>gocode -s -debug</code> </p>
<p>before you start your editor. Gocode will log when it tries to make suggestions including when it can't. Usually, you need to recompile a (sub) package manually if autocompletion isn't working. I suggest deleting the built package in <code>$GOPATH/pkg/<architecture>...</code> sub directory as well.</p></pre>Crossi36: <pre><p>Recompiling the package did it for me. Thank you very much!</p></pre>-Nii-: <pre><p>Gocode uses <code>.a</code> files for code completion. Issue where this was mentioned is found <a href="https://github.com/nsf/gocode/issues/296">here</a>.</p>
<blockquote>
<p>When it comes to imported packages, gocode doesn't look into their source code at all. It only uses .a files, which are compiled packages.</p>
</blockquote></pre>bkeroack: <pre><p>You have to <code>go get</code> the package first.</p></pre>joefitzgerald: <pre><p>go-plus author here. As others have mentioned, gocode is used for autocompletion. You should first make sure you have run <code>go get -u <package name here></code>. If the package you are getting requires a build step (because it is not go get compatible), perform that step.</p>
<p>Then, if you're still having problems (particularly with code you are writing yourself that is in separate packages), you might want to check your gocode settings (run <code>gocode set</code>). In particular, you want to make sure you have autobuild set to true (<code>gocode set autobuild true</code>).</p>
<p>Let me know if there is anything else I can do to help.</p></pre>Crossi36: <pre><p>Recompiling the package did it for me. </p>
<blockquote>
<p>if you're still having problems</p>
</blockquote>
<p>I just checked the gocode option <code>autobuild</code>, which is set to <code>false</code>. Should I set that preemptively to <code>true</code> even though I don't have problems anymore at the moment?</p></pre>joefitzgerald: <pre><p>In general, yes, you want autobuild set to true.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传