@@ -14,7 +14,6 @@ import (
1414 "fmt"
1515 "hash"
1616 "io"
17- "io/ioutil"
1817 "net"
1918 "os"
2019 "os/exec"
@@ -202,7 +201,7 @@ type ClientConfig struct {
202201 // SyncStdout, SyncStderr can be set to override the
203202 // respective os.Std* values in the plugin. Care should be taken to
204203 // avoid races here. If these are nil, then this will be set to
205- // ioutil .Discard.
204+ // io .Discard.
206205 SyncStdout io.Writer
207206 SyncStderr io.Writer
208207
@@ -401,7 +400,7 @@ func NewClient(config *ClientConfig) (c *Client) {
401400 }
402401
403402 if config .Stderr == nil {
404- config .Stderr = ioutil .Discard
403+ config .Stderr = io .Discard
405404 }
406405
407406 if config .SyncStdout == nil {
@@ -853,15 +852,15 @@ func (c *Client) Start() (addr net.Addr, err error) {
853852 var coreProtocol int
854853 coreProtocol , err = strconv .Atoi (parts [0 ])
855854 if err != nil {
856- err = fmt .Errorf ("Error parsing core protocol version: %s" , err )
855+ err = fmt .Errorf ("error parsing core protocol version: %s" , err )
857856 return
858857 }
859858
860859 if coreProtocol != CoreProtocolVersion {
861- err = fmt .Errorf ("Incompatible core API version with plugin. " +
860+ err = fmt .Errorf ("incompatible core API version with plugin. " +
862861 "Plugin version: %s, Core version: %d\n \n " +
863862 "To fix this, the plugin usually only needs to be recompiled.\n " +
864- "Please report this to the plugin author. " , parts [0 ], CoreProtocolVersion )
863+ "Please report this to the plugin author" , parts [0 ], CoreProtocolVersion )
865864 return
866865 }
867866 }
@@ -887,10 +886,16 @@ func (c *Client) Start() (addr net.Addr, err error) {
887886 switch network {
888887 case "tcp" :
889888 addr , err = net .ResolveTCPAddr ("tcp" , address )
889+ if err != nil {
890+ return nil , err
891+ }
890892 case "unix" :
891893 addr , err = net .ResolveUnixAddr ("unix" , address )
894+ if err != nil {
895+ return nil , err
896+ }
892897 default :
893- err = fmt .Errorf ("Unknown address type: %s" , address )
898+ return nil , fmt .Errorf ("unknown address type: %s" , address )
894899 }
895900
896901 // If we have a server type, then record that. We default to net/rpc
@@ -908,7 +913,7 @@ func (c *Client) Start() (addr net.Addr, err error) {
908913 }
909914 }
910915 if ! found {
911- err = fmt .Errorf ("Unsupported plugin protocol %q. Supported: %v" ,
916+ err = fmt .Errorf ("unsupported plugin protocol %q. Supported: %v" ,
912917 c .protocol , c .config .AllowedProtocols )
913918 return addr , err
914919 }
@@ -1041,7 +1046,7 @@ func (c *Client) checkProtoVersion(protoVersion string) (int, PluginSet, error)
10411046 return version , plugins , nil
10421047 }
10431048
1044- return 0 , nil , fmt .Errorf ("Incompatible API version with plugin. " +
1049+ return 0 , nil , fmt .Errorf ("incompatible API version with plugin. " +
10451050 "Plugin version: %d, Client versions: %d" , serverVersion , clientVersions )
10461051}
10471052
@@ -1097,8 +1102,8 @@ func (c *Client) Protocol() Protocol {
10971102 return c .protocol
10981103}
10991104
1100- func netAddrDialer (addr net.Addr ) func (string , time. Duration ) (net.Conn , error ) {
1101- return func (_ string , _ time. Duration ) (net.Conn , error ) {
1105+ func netAddrDialer (addr net.Addr ) func (context. Context , string ) (net.Conn , error ) {
1106+ return func (context. Context , string ) (net.Conn , error ) {
11021107 // Connect to the client
11031108 conn , err := net .Dial (addr .Network (), addr .String ())
11041109 if err != nil {
@@ -1115,7 +1120,7 @@ func netAddrDialer(addr net.Addr) func(string, time.Duration) (net.Conn, error)
11151120
11161121// dialer is compatible with grpc.WithDialer and creates the connection
11171122// to the plugin.
1118- func (c * Client ) dialer (_ string , timeout time. Duration ) (net.Conn , error ) {
1123+ func (c * Client ) dialer (ctx context. Context , _ string ) (net.Conn , error ) {
11191124 muxer , err := c .getGRPCMuxer (c .address )
11201125 if err != nil {
11211126 return nil , err
@@ -1128,7 +1133,7 @@ func (c *Client) dialer(_ string, timeout time.Duration) (net.Conn, error) {
11281133 return nil , err
11291134 }
11301135 } else {
1131- conn , err = netAddrDialer (c .address )("" , timeout )
1136+ conn , err = netAddrDialer (c .address )(ctx , "" )
11321137 if err != nil {
11331138 return nil , err
11341139 }
0 commit comments