Skip to main content

How to connect to a Temporal Cluster in Go

Use the Dial() API available in the package to create a new Client.

If you don't provide HostPort, the Client defaults the address and port number to

Set a custom Namespace name in the Namespace field on an instance of the Client Options.

Use the ConnectionOptions API to connect a Client with mTLS.

import (
// ...

func main() {
cert, err := tls.LoadX509KeyPair(clientCertPath, clientKeyPath)
if err != nil {
return err
client, err := client.Dial(client.Options{
HostPort: "",
Namespace: "your-custom-namespace",
ConnectionOptions: client.ConnectionOptions{
TLS: &tls.Config{Certificates: []tls.Certificate{cert}},
defer temporalClient.Close()
// ...