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

Commit

Permalink
Map remote go module cache to local module cache (#3079)
Browse files Browse the repository at this point in the history
  • Loading branch information
fnmunhoz committed Apr 22, 2020
1 parent dfa9cbb commit d3c0757
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/debugAdapter/goDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -843,14 +843,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)
);
}
}
return pathToConvert
.replace(this.delve.remotePath, this.delve.program)
Expand Down

0 comments on commit d3c0757

Please sign in to comment.