conn, err := redis.Dial("tcp", "localhost:6379") if err != nil { log.Fatal(err) } defer conn.Close() reply, err := conn.Do("SET", "mykey", "myvalue") if err != nil { log.Fatal(err) } fmt.Println(reply)
conn, err := redis.Dial("tcp", "localhost:6379") if err != nil { log.Fatal(err) } defer conn.Close() reply, err := conn.Do("GET", "mykey") if err != nil { log.Fatal(err) } fmt.Println(reply)This example connects to Redis, sends a GET command to retrieve the value of the "mykey" key, and prints the response from Redis. In both examples, the 'conn.Do' method is used to send Redis commands and retrieve their responses.