Docs

Go

valkey-go and go-redis.

Each example reads the connection URL from VALKEY_URL; copy it from your instance page in the dashboard. See connection details and limits for what applies to every client.

On this page: valkey-go · go-redis

valkey-go

The official Valkey client, which also works with Redis instances. ParseURL reads the rediss:// URL and sets up TLS with the right server name.

Install
go get github.com/valkey-io/valkey-go
main.go
package main import (	"context"	"fmt"	"os"	"time" 	"github.com/valkey-io/valkey-go") func main() {	opt, err := valkey.ParseURL(os.Getenv("VALKEY_URL"))	if err != nil {		panic(err)	}	client, err := valkey.NewClient(opt)	if err != nil {		panic(err)	}	defer client.Close() 	ctx := context.Background()	if err := client.Do(ctx, client.B().Set().Key("greeting").Value("hello").Ex(time.Minute).Build()).Error(); err != nil {		panic(err)	}	greeting, err := client.Do(ctx, client.B().Get().Key("greeting").Build()).ToString()	if err != nil {		panic(err)	}	fmt.Println(greeting)}

go-redis

go-redis v9, the official Redis client, works with both Redis and Valkey instances. ParseURL turns on TLS for rediss:// URLs.

Install
go get github.com/redis/go-redis/v9
main.go
package main import (	"context"	"fmt"	"os"	"time" 	"github.com/redis/go-redis/v9") func main() {	opt, err := redis.ParseURL(os.Getenv("VALKEY_URL"))	if err != nil {		panic(err)	}	client := redis.NewClient(opt)	defer client.Close() 	ctx := context.Background()	if err := client.Set(ctx, "greeting", "hello", time.Minute).Err(); err != nil {		panic(err)	}	fmt.Println(client.Get(ctx, "greeting").Val())}

© 2026 KVNest · Managed Redis and Valkey, hosted in the EU

Redis is a registered trademark of Redis Ltd. Any rights therein are reserved to Redis Ltd. KVNest is not affiliated with or endorsed by Redis Ltd.