-
Notifications
You must be signed in to change notification settings - Fork 645
Map remote go module cache to local module cache #3079
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -846,14 +846,29 @@ class GoDebugSession extends LoggingDebugSession { | |
return this.convertDebuggerPathToClient(pathToConvert); | ||
} | ||
|
||
// Fix for https://github.com/Microsoft/vscode-go/issues/1178 | ||
// When the pathToConvert is under GOROOT, replace the remote GOROOT with local GOROOT | ||
// When the pathToConvert is under GOROOT or Go module cache, replace path appropriately | ||
if (!pathToConvert.startsWith(this.delve.remotePath)) { | ||
// Fix for https://github.com/Microsoft/vscode-go/issues/1178 | ||
const index = pathToConvert.indexOf(`${this.remotePathSeparator}src${this.remotePathSeparator}`); | ||
const goroot = process.env['GOROOT']; | ||
if (goroot && index > 0) { | ||
return path.join(goroot, pathToConvert.substr(index)); | ||
} | ||
|
||
const indexGoModCache = pathToConvert.indexOf( | ||
`${this.remotePathSeparator}pkg${this.remotePathSeparator}mod${this.remotePathSeparator}` | ||
); | ||
const gopath = (process.env['GOPATH'] || '').split(path.delimiter)[0]; | ||
|
||
if (gopath && indexGoModCache > 0) { | ||
return path.join( | ||
gopath, | ||
pathToConvert | ||
.substr(indexGoModCache) | ||
.split(this.remotePathSeparator) | ||
.join(this.localPathSeparator) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just thought of one problem with this logic. Even if you are replacing the local path separator by the remote path separator, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will have to do similar changes like you did to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That sounds good. |
||
); | ||
} | ||
} | ||
return pathToConvert | ||
.replace(this.delve.remotePath, this.delve.program) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gopath
can potentially have multiple paths with the path separator specific to the OS platform. In that case, we can't use it inpath.join
directly this way.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does /pkg/mod apply to the first path in the gopath? Is there a rule around this?
Also, we need to ensure the right path separators are being used like we did in #3108
cc @quoctruong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I'm not sure where this is specified, but you can see
goimports
relying on this fact here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @stamblerre
@fnmunhoz, @quoctruong I have pushed a commit to use the first go path, can either of you test this one more time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ramya-rao-a sure I'll try to do it today and let you know. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ramya-rao-a I just double checked the extension after the change you made and it works fine for me, I was able to debug all files, including libraries inside go mod cache.
Thanks!