Skip to content

Instantly share code, notes, and snippets.

@serinth
Created May 21, 2018 05:28
Show Gist options
  • Save serinth/5f6e7724f30a69f6b5dcf23a03a8a140 to your computer and use it in GitHub Desktop.
Save serinth/5f6e7724f30a69f6b5dcf23a03a8a140 to your computer and use it in GitHub Desktop.
grpc connect with insecure
func connect(clientURL string) *grpc.ClientConn {
var opts []grpc.DialOption
opts = append(opts, grpc.WithInsecure())
ctx, cancel := context.WithTimeout(context.Background(), 30 * time.Second)
defer cancel()
con, err := grpc.DialContext(ctx, clientURL, opts...)
if err != nil {
log.Fatalf("Failed to start gRPC connection: %v", err)
}
return con
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment