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

x/tools/gopls: directoryFilters are mishandled when descending the workspace root to find a go.mod file #45340

Closed
wtlangford opened this issue Apr 1, 2021 · 3 comments
Labels
gopls/workspace gopls Tools

Comments

@wtlangford
Copy link

@wtlangford wtlangford commented Apr 1, 2021

What did you do?

Configured gopls in vscode as follows:

"gopls": {
  "build.directoryFilters": [
    "-some/dir",
    "+some/dir/moduleroot"
  ]
}

Where some/dir/moduleroot contains a go.mod.

What did you expect to see?

gopls detects the go.mod file in some/dir/moduleroot and uses it.

What did you see instead?

gopls did not detect the go.mod file and was unable to resolve any imports.

Build info

golang.org/x/tools/gopls v0.6.9
    golang.org/x/tools/gopls@v0.6.9 h1:LBBcE2y3Tb4bp79JVLWCQBbvYCFEs5ADGWsQDoSLk1Q=
    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/google/go-cmp@v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/mod@v0.4.1 h1:Kvvh58BN8Y9/lBi7hTekvtMpm07eUZ0ck5pRHpsMWrY=
    golang.org/x/sync@v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck=
    golang.org/x/sys@v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk=
    golang.org/x/tools@v0.1.1-0.20210319172145-bda8f5cee399 h1:O5bm8buX/OaamnfcBrkjn0SPUIU30jFmaS8lP+ikkxs=
    golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
    honnef.co/go/tools@v0.1.1 h1:EVDuO03OCZwpV2t/tLLxPmPiomagMoBOgfPt0FM+4IY=
    mvdan.cc/gofumpt@v0.1.0 h1:hsVv+Y9UsZ/mFZTxJZuHVI6shSQCtzZ11h1JEFPAZLw=
    mvdan.cc/xurls/v2@v2.2.0 h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A=
@gopherbot gopherbot added Tools gopls labels Apr 1, 2021
@gopherbot gopherbot added this to the Unreleased milestone Apr 1, 2021
@heschi
Copy link
Contributor

@heschi heschi commented Apr 1, 2021

I believe I made a stupid mistake in findModules: we don't recurse into a directory that is filtered out, which means that cases exactly like this one won't work. For now it'd probably be easier to recurse unconditionally, but that's unfortunate if the filter is (e.g.) node_modules.

@wtlangford
Copy link
Author

@wtlangford wtlangford commented Apr 1, 2021

You could also potentially look to see if there are any later + entries that have the - entry as a prefix and only recurse in that case.

@stamblerre stamblerre removed this from the Unreleased milestone Apr 1, 2021
@stamblerre stamblerre added this to the gopls/v1.0.0 milestone Apr 1, 2021
@stamblerre stamblerre added this to To Do in gopls on-deck Apr 15, 2021
@stamblerre stamblerre moved this from To Do to P2 in gopls on-deck Aug 12, 2021
@findleyr findleyr added the gopls/workspace label May 10, 2022
@findleyr findleyr removed this from the gopls/later milestone May 18, 2022
@findleyr findleyr added this to the gopls/v0.9.0 milestone May 18, 2022
@findleyr
Copy link
Contributor

@findleyr findleyr commented Jul 1, 2022

I believe at this point this is a dupe of #52970: modules can be excluded using go.work files, but we need to reconcile this with the directoryFilters setting.

@findleyr findleyr closed this as not planned Jul 1, 2022
@findleyr findleyr removed this from the gopls/v0.9.0 milestone Jul 1, 2022
@findleyr findleyr added this to the gopls/unplanned milestone Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls/workspace gopls Tools
Projects
No open projects
Development

No branches or pull requests

5 participants