Go language client in the Redis official network has a lot of L client, personal feeling Redigo use more humane, important is the source code structure is very clear, it is important to support pipeline, publish and subscribe, connection pool and so on, so I chose Redigo as an attempt.
Installation of 1.redigo
Terminal operation:go get github.com/garyburd/redigo/redis ,安装完成后在$GOPATH/src下有相关的文件目录
这是正常的安装方式,不知道什么原因,这块我死活安装不成功.
No way, download the Redigo-master.zip project package directly from GitHub online and copy the Redis folder directly to the $gopath/src/github.com/garyburd/redigo
2. Test Redigo
The virtual machine starts the Redis service, opens Liteide, and adds a go file:
Redistest Project Main.gopackage mainimport ("FMT" "Github.com/garyburd/redigo/redis") func main () {c, err: = Redis. Dial ("TCP", "192.168.74.128:6379") if err! = Nil {fmt. PRINTLN (ERR) return}//password authorization c. Do ("AUTH", "123456") c.do ("SET", "a", 134) A, err: = Redis. Int (C.do ("GET", "a")) FMT. Println (a) defer c.close ()}
Run after compiling the build and print out the correct results.
Golang access to Redis first experience