2020-02-18 10:47:19 -07:00
|
|
|
// 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
|
|
|
|
|
2020-02-26 14:22:54 -07:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os/exec"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2020-03-05 15:54:57 -07:00
|
|
|
startRemote = startRemoteDefault
|
|
|
|
autoNetworkAddress = autoNetworkAddressDefault
|
|
|
|
verifyRemoteOwnership = verifyRemoteOwnershipDefault
|
2020-02-26 14:22:54 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func startRemoteDefault(goplsPath string, args ...string) error {
|
|
|
|
cmd := exec.Command(goplsPath, args...)
|
|
|
|
if err := cmd.Start(); err != nil {
|
2020-05-01 08:05:39 -06:00
|
|
|
return fmt.Errorf("starting remote gopls: %w", err)
|
2020-02-26 14:22:54 -07:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-02-18 10:47:19 -07:00
|
|
|
// autoNetworkAddress returns the default network and address for the
|
|
|
|
// automatically-started gopls remote. See autostart_posix.go for more
|
|
|
|
// information.
|
2020-02-26 14:22:54 -07:00
|
|
|
func autoNetworkAddressDefault(goplsPath, id string) (network string, address string) {
|
2020-02-18 10:47:19 -07:00
|
|
|
if id != "" {
|
|
|
|
panic("identified remotes are not supported on windows")
|
|
|
|
}
|
2020-03-05 15:54:57 -07:00
|
|
|
return "tcp", "localhost:37374"
|
|
|
|
}
|
|
|
|
|
|
|
|
func verifyRemoteOwnershipDefault(network, address string) (bool, error) {
|
|
|
|
return true, nil
|
2020-02-18 10:47:19 -07:00
|
|
|
}
|