diff --git a/internal/lsp/source/uri.go b/internal/lsp/source/uri.go index 2d7049f6..59429292 100644 --- a/internal/lsp/source/uri.go +++ b/internal/lsp/source/uri.go @@ -8,6 +8,7 @@ import ( "fmt" "net/url" "path/filepath" + "runtime" "strings" ) @@ -36,5 +37,11 @@ func (uri URI) Filename() (string, error) { // ToURI returns a protocol URI for the supplied path. // It will always have the file scheme. func ToURI(path string) URI { + const prefix = "$GOROOT" + if strings.EqualFold(prefix, path[:len(prefix)]) { + suffix := path[len(prefix):] + //TODO: we need a better way to get the GOROOT that uses the packages api + path = runtime.GOROOT() + suffix + } return URI(fileSchemePrefix + filepath.ToSlash(path)) }