package redisrpc import ( "github.com/golang/protobuf/proto" ) /** * 使用用户名查询 */ func GetByKey(key string, url ...string) (string, error) { var user_rpc_url string = "127.0.0.1:7953" if len(url) > 0 && url[0] != "" { user_rpc_url = url[0] } conn, _, err := DialRedisService("tcp", user_rpc_url) if err != nil { return "", err } defer conn.Close() req := &GetKey{proto.String(key), nil} res := &GetResponse{} err = conn.GetByKey(req, res) if err != nil { return "", err } return res.GetString_(), nil }