github.com/v2fly/tools@v0.100.0/internal/lsp/lsprpc/autostart_default.go (about) 1 // Copyright 2020 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package lsprpc 6 7 import ( 8 exec "golang.org/x/sys/execabs" 9 10 errors "golang.org/x/xerrors" 11 ) 12 13 var ( 14 startRemote = startRemoteDefault 15 autoNetworkAddress = autoNetworkAddressDefault 16 verifyRemoteOwnership = verifyRemoteOwnershipDefault 17 ) 18 19 func startRemoteDefault(goplsPath string, args ...string) error { 20 cmd := exec.Command(goplsPath, args...) 21 if err := cmd.Start(); err != nil { 22 return errors.Errorf("starting remote gopls: %w", err) 23 } 24 return nil 25 } 26 27 // autoNetworkAddress returns the default network and address for the 28 // automatically-started gopls remote. See autostart_posix.go for more 29 // information. 30 func autoNetworkAddressDefault(goplsPath, id string) (network string, address string) { 31 if id != "" { 32 panic("identified remotes are not supported on windows") 33 } 34 return "tcp", "localhost:37374" 35 } 36 37 func verifyRemoteOwnershipDefault(network, address string) (bool, error) { 38 return true, nil 39 }