Skip to content

Go Example (redigo)

Josh Baker edited this page Jan 2, 2017 · 6 revisions

redigo project page

Install

go get github.com/garyburd/redigo/redis

Example

package main

import (
	"fmt"
	"log"
	"github.com/garyburd/redigo/redis"
)

func main() {
	c, err := redis.Dial("tcp", ":9851")
	if err != nil {
		log.Fatalf("Could not connect: %v\n", err)
	}
	defer c.Close()

	ret, _ := c.Do("SET","fleet", "truck1", "POINT", "33", "-115")
	fmt.Printf("%s\n", ret)

	ret, _ = c.Do("GET","fleet", "truck1")
	fmt.Printf("%s\n", ret)

}

Thanks to Jonatan Reiners for providing this example code

Clone this wiki locally