Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gocode add restful api #498

Open
yeskeen opened this issue Feb 11, 2018 · 1 comment
Open

gocode add restful api #498

yeskeen opened this issue Feb 11, 2018 · 1 comment

Comments

@yeskeen
Copy link

yeskeen commented Feb 11, 2018

I am using visual studio code + go extension, when request autocomplete ,first send 'gocode set' to get config,then send custom config like gocode set lib-path '/', after that send gocode autocomplete.. command to get autocomplete list. It will call gocode program(about 10M) three times, I'm not using ssd,so it const about 1.2 seconds to show the autocomplete list.
Simply, I modified the gocode client code, add http service(37374) for commands, and write results to http response,
then modified the vsc-go plugin ,using http method instead of calling gocode .
After that, it's very very fast.
So, I think gocode server can provide a restful api .

@nsf
Copy link
Owner

nsf commented Feb 11, 2018

It's a wrong assumption on your side. There is this thing called file cache. Most operating systems do have one. OS caches recently read files in-memory in case if you have free RAM for it. Usually these days people have quite a lot of RAM. Assumption that binary is always re-read from HDD is wrong. I can guarantee that this does not happen on linux. Most likely same behaviour is true for other modern OSes as well.

Now as for what visual studio code plugin does - I don't know. With the right setup gocode can return autocompletion response in less than ~100ms for most cases. However "gocode set" command drops gocode cache and gocode ends up re-reading the whole set of libraries your currently edited project uses. Blame vscode plugin authors for that if that's true. If you want an advice from me: gocode set should never be used by any of the editor plugins. And even more: most gocode users should not use lib-path config option. It was added as hack to handle weird setups such as google's appengine Go integration in the early days. I'm not sure if it's relevant anymore.

I will not add RESTful API to gocode. Hopefully sooner or later gocode will be replaced by a better language server protocol based service if somebody writes it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants