package main
import (
"fmt"
"github.com/garyburd/redigo/redis"
)
func main() {
conn, err := redis.Dial("tcp", "192.168.5.104:6379")
if err != nil {
fmt.Println("redis.Dial err = ", err)
return
}
defer conn.Close()
_, err = conn.Do("Set", "name", "tomje 猫")
if err != nil {
fmt.Println("Set err = ", err)
return
}
r, err := redis.String(conn.Do("Get", "name"))
if err != nil {
fmt.Println("Get err = ", err)
return
}
fmt.Println(" *** 作OK :", r)
}
这个错误应该是网络问题的,查看服务器的防火墙
#关闭防火墙
@localhost ~]# systemctl stop firewalld
@localhost ~]# systemctl disable firewalld
@localhost ~]# systemctl status firewalld
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)