mirror of
https://github.com/golang/go
synced 2024-11-18 21:14:44 -07:00
d1d1f200c6
When the gopls daemon is automatically managed (-remote=auto), it will be started by one of the forwarder gopls processes that was in turn started by the editor. By default, this puts it in the same process group as the forwarder gopls. Some editors (at least Vim) send SIGTERM to the process groups of sidecar processes when exiting. This can cause the gopls daemon to terminate, thereby losing state. Rather than ignore SIGTERM (which is bound to be editor dependent anyway), let's just put the gopls daemon in a separate session. Updates golang/go#34111 Change-Id: I71386fb54b8c2efe1c565f59763f46693a7d48b0 Reviewed-on: https://go-review.googlesource.com/c/tools/+/221220 Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
34 lines
868 B
Go
34 lines
868 B
Go
// Copyright 2020 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package lsprpc
|
|
|
|
import (
|
|
"fmt"
|
|
"os/exec"
|
|
)
|
|
|
|
var (
|
|
startRemote = startRemoteDefault
|
|
autoNetworkAddress = autoNetworkAddressDefault
|
|
)
|
|
|
|
func startRemoteDefault(goplsPath string, args ...string) error {
|
|
cmd := exec.Command(goplsPath, args...)
|
|
if err := cmd.Start(); err != nil {
|
|
return fmt.Errorf("starting remote gopls: %v", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// autoNetworkAddress returns the default network and address for the
|
|
// automatically-started gopls remote. See autostart_posix.go for more
|
|
// information.
|
|
func autoNetworkAddressDefault(goplsPath, id string) (network string, address string) {
|
|
if id != "" {
|
|
panic("identified remotes are not supported on windows")
|
|
}
|
|
return "tcp", ":37374"
|
|
}
|