rogpeppe / godef

Print where symbols are defined in Go source code
BSD 3-Clause "New" or "Revised" License
666 stars 142 forks source link

Go to Definition is not considering the GOHOSTOS' when the function is defined for multiple GOHOSTOS' #59

Open ramya-rao-a opened 7 years ago

ramya-rao-a commented 7 years ago

From @Zignd on April 15, 2017 18:42

I was using Windows, I tried to Go to Definition on a call to the rename function (internal function in the os package), and the function definition for Plan 9 opened in my editor.

The rename function has definitions in GOROOT/src/os/file_plan9.go, GOROOT/src/os/file_unix.go, and in GOROOT/src/os/file_windows.go.

I was expecting the extension to open the definition from the GOROOT/src/os/file_windows.go file.

Copied from original issue: Microsoft/vscode-go#927

ramya-rao-a commented 7 years ago

I am on a Mac, and for me the definition in GOROOT/src/os/file.go opens.

@rakyll What is the expectation here?

ramya-rao-a commented 7 years ago

From @Zignd on April 15, 2017 23:6

Oh, it's not the os.Rename function, it's the os.rename function. os.rename is called from within os.Rename to perform the rename according to a specific operating system. I just tried it on Linux and the same occurs, GOROOT/src/os/file_plan9.go opens.

// Rename renames (moves) oldpath to newpath.
// If newpath already exists and is not a directory, Rename replaces it.
// OS-specific restrictions may apply when oldpath and newpath are in different directories.
// If there is an error, it will be of type *LinkError.
func Rename(oldpath, newpath string) error {
    return rename(oldpath, newpath)
}

Here's a snippet containing the os.Rename definition, as you can see it is calling os.rename.

ramya-rao-a commented 7 years ago

@Zignd Ah, got it.

I tried on my Mac again, and the definition in file_unix.go opened for me.

But on Windows, I can repro what you are seeing i.e file_plan9.go opens. If I update my settings to use the gogetdoc tool instead (set "go.docsTool": "gogetdoc"), then I get navigated to the right file.

Can you try using gogetdoc and see if that helps?

If it does, then this issue should be moved to the repo for godef

ramya-rao-a commented 7 years ago

From @Zignd on April 16, 2017 15:12

@ramya-rao-a It works when I set "go.docsTool": "gogetdoc". It seems to be an issue with godef as you said. Should I open an issue there?