Skip to content

Commit

Permalink
internal/lsp/lsprpc: prefer XDG_RUNTIME_DIR for the daemon socket
Browse files Browse the repository at this point in the history
If XDG_RUNTIME_DIR is set, it makes more sense as a location for the
gopls daemon socket than TMPDIR.

This avoids auto discovery issues when TMPDIR is overridden for certain
editors.

For golang/go#41266

Change-Id: I5a0a20c6185ca60d8ff03b8d948b17a636aa8404
Reviewed-on: https://go-review.googlesource.com/c/tools/+/274272
Trust: Robert Findley <[email protected]>
Run-TryBot: Robert Findley <[email protected]>
Reviewed-by: Heschi Kreinick <[email protected]>
gopls-CI: kokoro <[email protected]>
TryBot-Result: Go Bot <[email protected]>
  • Loading branch information
findleyr committed Dec 1, 2020
1 parent 7e522c8 commit 7470481
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/lsp/lsprpc/autostart_posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ func autoNetworkAddressPosix(goplsPath, id string) (network string, address stri
if id != "" {
idComponent = "-" + id
}
return "unix", filepath.Join(os.TempDir(), fmt.Sprintf("%s-%s-daemon.%s%s", basename, shortHash, user, idComponent))
runtimeDir := os.TempDir()
if xdg := os.Getenv("XDG_RUNTIME_DIR"); xdg != "" {
runtimeDir = xdg
}
return "unix", filepath.Join(runtimeDir, fmt.Sprintf("%s-%s-daemon.%s%s", basename, shortHash, user, idComponent))
}

func verifyRemoteOwnershipPosix(network, address string) (bool, error) {
Expand Down

0 comments on commit 7470481

Please sign in to comment.