01.redigo入门
# 01.安装和连接
# 1.1 安装
使用第三方开源的redis库: github.com/garyburd/redigo/redis
命令行输入 :
go get github.com/garyburd/redigo/redis
1
# 1.2 连接Redis
package main
import (
"fmt"
"github.com/garyburd/redigo/redis"
)
func main() {
c, err := redis.Dial("tcp", "localhost:6379")
if err != nil {
fmt.Println("conn redis failed,", err)
return
}
fmt.Println("redis conn success")
defer c.Close()
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
上次更新: 2024/3/13 15:35:10