import "github.com/garyburd/redigo/redis" c, err := redis.Dial("tcp", "localhost:6379") if err != nil { // handle error } defer c.Close() pong, err := c.Do("PING") if err != nil { // handle error } fmt.Println(pong) // Output: PONG
import "github.com/garyburd/redigo/redis" c, err := redis.Dial("tcp", "localhost:6379") if err != nil { // handle error } defer c.Close() _, err = c.Do("SET", "key", "value") if err != nil { // handle error } value, err := redis.String(c.Do("GET", "key")) if err != nil { // handle error } fmt.Println(value) // Output: valueIn this example, we use the `SET` and `GET` commands of Redis to store and retrieve a key-value pair. We send the commands to the server using the `Do` method of the `Conn` type, and receive the value using the `redis.String` helper function. Overall, the `garyburd/redigo/redis` package provides a convenient way to interact with Redis databases in Go applications.