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

can inferGopath look for "src" in the current directory? #1213

Closed
skybrian opened this issue Sep 14, 2017 · 7 comments
Closed

can inferGopath look for "src" in the current directory? #1213

skybrian opened this issue Sep 14, 2017 · 7 comments

Comments

@skybrian
Copy link

When go.inferGopath is on, the current behavior is that if you run:

% code src

Then the GOPATH is inferred. However, if you run:

% code .

Then it isn't. If src is not found in any parent directory, then it would be nice if it also checked if there is a child folder named src as well. This would allow the same workspace to be used to edit sibling directories of src.

(In my particular case, I have src and doc as siblings in the same repo and it would be nice to see both in the same window.)

@ramya-rao-a
Copy link
Contributor

Sure, we can have that as a fallback.
Will try to get this in next week

@ParadiseDS
Copy link

This feature in in urgent need! Plz let me know if it is on implementing.

@ramya-rao-a
Copy link
Contributor

There are 2 ways to do this:

  • Recursively check the children of the folder that was opened in VS Code looking for src folder
  • Or Look for src in the ancestors of the file that is currently open

I wouldn't prefer the first as in the worse case scenario we will be doing a whole lot of file stats.
The only downside of the second is that GOPATH will still not be inferred if no file is open, which I feel we can live with.

So I am going with the second option.
i.e if you open code . on the GOPATH or any of its ancestors, the GOPATH will be inferred only if any of the files under GOPATH is open in the editor

@skybrian
Copy link
Author

For what it's worth, a third option is:

  • Nonrecursively check that there is a child of the opened folder named "src".

That should only require one file stat.

@ParadiseDS
Copy link

For what it's worth, a third option is:

Nonrecursively check that there is a child of the opened folder named "src".

Agree. As the common case to have src as a child is a project expected be compiled and run out of the box, and in this case the work root is expected to be the GOPATH, with src as its direct child.

@ramya-rao-a
Copy link
Contributor

Fair enough, done with 5f5cad5

@ramya-rao-a
Copy link
Contributor

This fix is now out in the latest update to the Go extension (0.6.71)

@vscodebot vscodebot bot locked and limited conversation to collaborators Feb 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants