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/cmd/guru: handle source file aliasing gracefully #17515

Closed
alandonovan opened this issue Oct 19, 2016 · 1 comment
Closed

x/tools/cmd/guru: handle source file aliasing gracefully #17515

alandonovan opened this issue Oct 19, 2016 · 1 comment
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@alandonovan
Copy link
Contributor

alandonovan commented Oct 19, 2016

guru uses textual (not inode) equality to compare filenames in some places. As a result, file name aliases arising from symbolic links confuse the tool. For example, many users set GOPATH=$HOME and add a symbolic link $HOME/src -> $HOME/somedir/src. If the file name used in the guru command (which is the file name of the editor buffer) does not match the file name used in the GOPATH variable, the tool reports the wrong result.

In the session below, $HOME/gotN is the actual workspace directory and $HOME/src is an alias of $HOME/gotN/src. In the first two commands, the GOPATH and filenames match and the commands succeed; in the second two commands they do not match and so they fail. NOTE: the bug was partially masked by https://go-review.googlesource.com/c/30451, so the session below makes sense only if we roll back to before that change. (The fix can be evaluated with a unit test of guru's pkgContainsFile function.)

$ GOPATH=$/HOME/gotN guru  implements ~/gotN/src/foo/main.go:#19
/home/adonovan/gotN/src/foo/main.go:3:6: struct type T
/home/adonovan/gotN/src/foo/main.go:7:6:       implements I

$ GOPATH=$HOME guru  implements ~/src/foo/main.go:#19
/home/adonovan/src/foo/main.go:3:6: struct type T
/home/adonovan/src/foo/main.go:7:6:    implements I

$ GOPATH=$HOME guru  implements ~/gotN/src/foo/main.go:#19
guru: directory /home/adonovan/gotN/src/foo is not beneath any of these GOROOT/GOPATH directories: /home/adonovan/go/src, /home/adonovan/src

$ GOPATH=$/HOME/gotN guru  implements ~/src/foo/main.go:#19
guru: directory /home/adonovan/src/foo is not beneath any of these GOROOT/GOPATH directories: /home/adonovan/go/src, /home/adonovan/gotN/src
@quentinmit quentinmit changed the title guru: handle source file aliasing gracefully x/tools/cmd/guru: handle source file aliasing gracefully Oct 20, 2016
@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 20, 2016
@quentinmit quentinmit added this to the Unreleased milestone Oct 20, 2016
@gopherbot
Copy link

CL https://golang.org/cl/33858 mentions this issue.

@golang golang locked and limited conversation to collaborators Dec 2, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants