package redisrpc import ( "github.com/golang/protobuf/proto" ) /** * 使用用户名查询 */ func GetByHashKey(key, field 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 := &GetHashKey{proto.String(key), proto.String(field), nil} res := &GetResponse{} err = conn.GetByHashKey(req, res) if err != nil { return "", err } return res.GetString(), nil }