Unable to navigate to public functions in vendor lib

I am having a strange issue wherein the vendor directory is recognized, but any non-static (instance methods) methods from vendor libraries used in my project show up in red, and are not navigable.  Here is an example where my static method from vendor lib looks fine and is navigable (uuid.NewRandom), while the instance method (uuid.String()) looks red and is non-navigable.  Any idea what I am missing here?  (Go version - 1.11.4, GoLand version - 2018.3.5).  Any idea what I am missing?

 

3 comments
Comment actions Permalink

Where the `uuid` package is located exactly? Where IDE leads you on Ctrl+click on /uuid? Is Go modules integration enabled for the project?

 

0
Comment actions Permalink

Hi Alexander, thanks for responding.  My uuid package is under the standard vendor directory in GOPATH. Here are the exact locations - 

My file

sample.go -> $GOPATH/src/myproject/sample/sample.go  

 

Referenced file

$GOPATH/src/vendor/github.com/google/uuid/version4.go

 

Like I said, my IDE was able to navigate to static methods (uuid.NewRandom), but is not recognizing the instance methods (uuid.String() in this case).

I don't believe I need to enable Go modules integration since I am just working with a single GOPATH. However, I tried enabling this based on your question.  Enabling it didn't seem to have any effect.  In fact it resulted in more errors in my workspace.  The good news though is, when I disabled it again my original issue got resolved.  My IDE can now see static methods as well as instance methods in vendor package.  This clearly seems like a bug to me.  But I guess I can live with that.  I know what to do when this happens again - just enable and disable "Go modules integration".

 

0
Comment actions Permalink

The problem is likely caused by the wrong paths in the project.

In your example:

My file

sample.go -> $GOPATH/src/myproject/sample/sample.go  

 

Referenced file

$GOPATH/src/vendor/github.com/google/uuid/version4.go

 

But they should be:

My file

sample.go -> $GOPATH/src/myproject/sample/sample.go  

 

Referenced file

$GOPATH/src/myproject/vendor/github.com/google/uuid/version4.go

 

And the IDE project should be created at $GOPATH/src/myproject

 

I hope this helps. If not, please let us know.

0

Please sign in to leave a comment.