Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

go to definition delay && doesn't work on some third-party packages #2222

Closed
@sunliver

Description

@sunliver

Example code and some tests:

https://github.com/sunliver/mod-test

After tested some third-party packages, I've found some third-party packages fail to go to definition(github.com/spf13/cobra), and some work very slow (github.com/spf13/viper). Results can be seen in my repo.

As the readme says,

  1. when you are outside the mod directory (for example, workspace dir), godef will fail on some cases
  2. godef works much slower than expected

Reason:

Current vscode-go extension misused the new godef, now always run godef on workspace dir.
Because new godef relays on packages to find definitions.
A quick example for verifying this => gopackages

So the new godef working with go mod, it should run inside the mod project, otherwise it will fallback to the old version.

├── gomod-test   => workspace dir
│   └── mod-test    => mod root
│       ├── Readme.md
│       ├── go.mod
│       ├── go.sum
│       ├── mod-test.go
│       └── modinner

How to fix

I've fixed this on this PR, or may other ways.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions