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

autocomplete not working for local packages #526

Closed
keyurva opened this issue Apr 14, 2014 · 51 comments
Closed

autocomplete not working for local packages #526

keyurva opened this issue Apr 14, 2014 · 51 comments

Comments

@keyurva
Copy link

@keyurva keyurva commented Apr 14, 2014

I'm using ST3 on windows with the gosublime plugin. I'm developing an app engine application. Auto-complete works fine for packages from the standard library as well as from the app engine SDK. But it does not for local packages.

I've gone through a couple of issues related to this topic but to no avail. Appreciate your help.

Thanks,
Keyur

@mackross
Copy link

@mackross mackross commented Jun 26, 2014

+1

@tj
Copy link

@tj tj commented Jul 15, 2014

I get this pretty often as well, works once or twice then fails to pick up changes or fails all together

@mackross
Copy link

@mackross mackross commented Jul 16, 2014

I've found if you import the packages all the way from your src folder it works. For example I'm working on a project in GO_PATH/src/github.com/mackross/projectA and I have two local packages GO_PATH/src/github.com/mackross/projectA/localPackageB and
GO_PATH/src/github.com/mackross/localPackageC.

I can get autocomplete by importing "github.com/mackross/projectA/localPackageB" & "github.com/mackross/localPackageC" rather than relative paths.

@amativos
Copy link

@amativos amativos commented Sep 12, 2014

+1 for the issue. Gets really annoying. I always import from the src folder - still doesn't work.

@rshmelev
Copy link

@rshmelev rshmelev commented Sep 12, 2014

+1, quite irritating.

@iamthemovie
Copy link

@iamthemovie iamthemovie commented Sep 14, 2014

+1

I'm assuming this is the same issue. From what I can tell, you have to rebuild / reinstall the local package for it to update the autocomplete.

I have: $GOPATH/github.com/myapp/package/functions.go and to get an updated autocomplete I have to:

go install myapp/package

Autocomplete then updates. Is this to do with it reading binaries rather than source?

@rshmelev
Copy link

@rshmelev rshmelev commented Sep 15, 2014

i'm calling "go install" on each ctrl+s using sublime "Command on Save" plugin.
it works almost perfectly (each save leads to 1-second lag now).

@iamthemovie
Copy link

@iamthemovie iamthemovie commented Sep 15, 2014

@rshmelev I wonder if the process can be run in the background rather than causing any visible lag.

@iamthemovie
Copy link

@iamthemovie iamthemovie commented Sep 15, 2014

I have a quick fix for it based on @rshmelev's comment.

https://github.com/iamthemovie/GoSublimeAutocompleteUpdate

@DisposaBlackSwan
Copy link

@DisposaBlackSwan DisposaBlackSwan commented Sep 15, 2014

Assuming you're all using the main GS repo and go install is all it takes to make it work, you can run it using the on_save setting https://github.com/DisposaBoy/GoSublime/blob/master/articles/golint.md

@codepushr
Copy link

@codepushr codepushr commented Sep 30, 2014

+1

1 similar comment
@zainhoda
Copy link

@zainhoda zainhoda commented Oct 23, 2014

+1

@veegee
Copy link

@veegee veegee commented Nov 17, 2014

+1

This plug in isn't well maintained anymore, is it? Are there any alternatives?

@ivpusic
Copy link

@ivpusic ivpusic commented Dec 5, 2014

+1

4 similar comments
@Volox
Copy link

@Volox Volox commented Feb 3, 2015

+1

@lukewilliamboswell
Copy link

@lukewilliamboswell lukewilliamboswell commented Feb 17, 2015

+1

@Graha
Copy link

@Graha Graha commented Feb 22, 2015

+1

@jaytaylor
Copy link

@jaytaylor jaytaylor commented Apr 1, 2015

+1

@jaytaylor
Copy link

@jaytaylor jaytaylor commented Apr 1, 2015

Local package auto-completion was working fine in ST3 until yesterday..now it is completely broken for me. Anyone have any advice or ideas on how to resolve?

I didn't know how much I appreciated this until I no longer had it. It's very annoying to go around opening files all the time to see what functions are available.

@jaytaylor
Copy link

@jaytaylor jaytaylor commented Apr 1, 2015

Additional note: local-package auto-completion also no longer works for me in ST2.

@jaytaylor
Copy link

@jaytaylor jaytaylor commented Apr 1, 2015

Alright, so I was able to fix it by taking the following steps:

  • Upgrading from go 1.4 to go 1.4.2
  • rm -rf ~/go/pkg/darwin_amd64

Cheers!

@coredump
Copy link

@coredump coredump commented Apr 13, 2015

Is there a way to do the gs9o_open solution work without opening the bottom console?

@tylerl
Copy link

@tylerl tylerl commented May 4, 2015

This problem goes away if you remove and re-create your personal GOPATH dir after go 1.4.2 upgrade.

@jaytaylor
Copy link

@jaytaylor jaytaylor commented May 4, 2015

Great info, thanks!

On May 3, 2015, at 11:28 PM, Tyler Larson notifications@github.com wrote:

This problem goes away if you remove and re-create your personal GOPATH dir after go 1.4.2 upgrade.


Reply to this email directly or view it on GitHub.

@coredump
Copy link

@coredump coredump commented May 4, 2015

What do you mean by recreate the path?

@codepushr
Copy link

@codepushr codepushr commented May 5, 2015

Like remove my go directory or my GOPATH env variable?

@jaytaylor
Copy link

@jaytaylor jaytaylor commented May 5, 2015

The directory - you want everything under $GOPATH/pkg to be wiped.

On May 4, 2015, at 5:31 PM, Aleksandar Palic notifications@github.com wrote:

Like remove my go directory or my GOPATH env variable?


Reply to this email directly or view it on GitHub.

@codepushr
Copy link

@codepushr codepushr commented May 5, 2015

Alright but it's still not working for me. I just refactored a function name and it's still suggesting the old name even after relaunching Sublime. I guess the point is not to always recreate the pkg folder.

@jaytaylor
Copy link

@jaytaylor jaytaylor commented May 5, 2015

I feel your pain, when it wasn't working for me I was pretty upset about it!

You may also try removing $GOHOME/pkg

e.g. /usr/local/go/pkg

On May 4, 2015, at 6:05 PM, Aleksandar Palic notifications@github.com wrote:

Alright but it's still not working for me. I just refactored a function name and it's still suggesting the old name even after relaunching Sublime. I guess the point is not to always recreate the pkg folder.


Reply to this email directly or view it on GitHub.

@robertobc
Copy link

@robertobc robertobc commented Jan 26, 2016

Any ideas? This just started happening. Seems like it was after I upgraded to go v1.5.3.

@jaytaylor
Copy link

@jaytaylor jaytaylor commented Jan 26, 2016

I definitely had similar issues the last time I upgraded go versions. Make sure to clear out previously compiled content from $GOPATH/pkg/*.

On Jan 25, 2016, at 9:10 PM, robertobc notifications@github.com wrote:

Any ideas? This just started happening. Seems like it was after I upgraded to go v1.5.3.


Reply to this email directly or view it on GitHub.

@tj
Copy link

@tj tj commented Jan 26, 2016

@robertobc might be hitting #670. I didn't touch a single thing on my machine, it was fine, I saw GoSublime update and display the changelog, and then had issues, nothing to do with GOPATH etc unless GoSublime is fiddling with things.

@robertobc
Copy link

@robertobc robertobc commented Jan 26, 2016

@tj It could be. I even tried reinstalling Sublime, Go and GoSublime. Still no luck.
The built in packages auto complete perfectly. The local ones don't.
I'm on OSX in case others are having issues on different platforms.

@codepushr
Copy link

@codepushr codepushr commented Jan 26, 2016

@robertobc Try building your projects without errors, this sometimes fixed it for me. I found switching to vim-go a better alternative anyway.

@robertobc
Copy link

@robertobc robertobc commented Jan 26, 2016

@codepushr In the past that usually fixed it for me as well. This time no luck though :(

@DisposaBoy
Copy link
Owner

@DisposaBoy DisposaBoy commented Jan 26, 2016

Some potentially useful information should be printed in the console after attempting completion on a package for the first time... other than that, and with no way to re-produce this, I can't help much

@robertobc
Copy link

@robertobc robertobc commented Jan 26, 2016

@DisposaBoy Thanks! I checked the console and for whatever reason this time I saw errors I never saw before. Seems like there was an error in the $GOPATH even though I hadn't changed it. Changing it to something new and then back fixed the issue.

@paulcwarren
Copy link

@paulcwarren paulcwarren commented Mar 4, 2016

+1 pls!

@monissiddiqui-zz
Copy link

@monissiddiqui-zz monissiddiqui-zz commented Mar 8, 2016

+1

1 similar comment
@GeekyVenkat
Copy link

@GeekyVenkat GeekyVenkat commented Mar 11, 2016

+1

@nishanttotla
Copy link

@nishanttotla nishanttotla commented Mar 18, 2016

I started having this issue recently after updating to Go version 1.6. Tried @robertobc's idea of updating and changing back GOPATH, but local package changes aren't being updated for autocomplete. Anyone have suggestions?

UPDATE: Running a go install on Mac for the repo fixed it.

@wolfgangmeyers
Copy link

@wolfgangmeyers wolfgangmeyers commented Aug 18, 2016

Also having this issue on 1.6. Importing from src makes no difference. Also not getting any autocomplete for some other packages, such as "github.com/stretchr/testify/mock". On ubuntu 16.04

@songleo
Copy link

@songleo songleo commented Sep 1, 2016

+1

@RomanMinkin
Copy link

@RomanMinkin RomanMinkin commented Oct 23, 2016

For govendor I have to ran following command every time I add a new package:

govendor install +vendor

fixed issue for me

Update: the correct command is govendor install +vendor, and i'm on OS X

@sharathbj
Copy link

@sharathbj sharathbj commented Feb 5, 2017

I think the only solution to this problem is https://packagecontrol.io/packages/All%20Autocomplete

Enjoy!!!

@ishanray
Copy link

@ishanray ishanray commented Jun 11, 2017

In Visual Studio Code, I can get autocomplete of builtin packages before importing.

package main

func main() {
    fmt.|
}

From here I can choose Println and after saving will autoimport the fmt package.

In GoSublime I need to import the package first before I see any completion. Is there a way to avoid that?

@songleo
Copy link

@songleo songleo commented Jun 22, 2017

@ishanray u can use goimports, add a configuration in GoSublime.sublime-settings:

    "fmt_cmd": ["goimports"],

you can get it by run cmd go get golang.org/x/tools/cmd/goimports

@ishanray
Copy link

@ishanray ishanray commented Jun 22, 2017

@songleo yes I do use goimports, but it requires me to save the file. In vscode even before saving the file I get autocomplete of local packages.

@ddrake12
Copy link

@ddrake12 ddrake12 commented Aug 15, 2017

+1

@paulwalker
Copy link

@paulwalker paulwalker commented Aug 22, 2017

FYI, for users of virtualgo (https://github.com/GetStream/vg), I found out that I needed to make sure to start sublime in the project directory and/or within a package directory located in the virtual GOPATH, so that sublime recognized the virtual GOPATH. You can user the "open log file" command to see the value that GoSublime (margo) uses.

@morganwu277
Copy link

@morganwu277 morganwu277 commented May 30, 2018

You can just follow this post:
https://morganwu277.github.io/2018/05/30/Setup-Golang-Dev-Env-in-Sublime-Text3/

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