golint warnings are removed

This commit is contained in:
Veselkov Konstantin 2018-01-24 22:38:47 +04:00
parent 4021ace056
commit ea4d6c3490
5 changed files with 44 additions and 44 deletions

View File

@ -81,9 +81,9 @@ func cmdFirstKeyPos(cmd Cmder, info *CommandInfo) int {
case "eval", "evalsha": case "eval", "evalsha":
if cmd.stringArg(2) != "0" { if cmd.stringArg(2) != "0" {
return 3 return 3
} else {
return 0
} }
return 0
case "publish": case "publish":
return 1 return 1
} }

View File

@ -37,25 +37,25 @@ func (r *Reader) Reset(rd io.Reader) {
r.src.Reset(rd) r.src.Reset(rd)
} }
func (p *Reader) PeekBuffered() []byte { func (r *Reader) PeekBuffered() []byte {
if n := p.src.Buffered(); n != 0 { if n := r.src.Buffered(); n != 0 {
b, _ := p.src.Peek(n) b, _ := r.src.Peek(n)
return b return b
} }
return nil return nil
} }
func (p *Reader) ReadN(n int) ([]byte, error) { func (r *Reader) ReadN(n int) ([]byte, error) {
b, err := readN(p.src, p.buf, n) b, err := readN(r.src, r.buf, n)
if err != nil { if err != nil {
return nil, err return nil, err
} }
p.buf = b r.buf = b
return b, nil return b, nil
} }
func (p *Reader) ReadLine() ([]byte, error) { func (r *Reader) ReadLine() ([]byte, error) {
line, isPrefix, err := p.src.ReadLine() line, isPrefix, err := r.src.ReadLine()
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -71,8 +71,8 @@ func (p *Reader) ReadLine() ([]byte, error) {
return line, nil return line, nil
} }
func (p *Reader) ReadReply(m MultiBulkParse) (interface{}, error) { func (r *Reader) ReadReply(m MultiBulkParse) (interface{}, error) {
line, err := p.ReadLine() line, err := r.ReadLine()
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -85,19 +85,19 @@ func (p *Reader) ReadReply(m MultiBulkParse) (interface{}, error) {
case IntReply: case IntReply:
return parseInt(line[1:], 10, 64) return parseInt(line[1:], 10, 64)
case StringReply: case StringReply:
return p.readTmpBytesValue(line) return r.readTmpBytesValue(line)
case ArrayReply: case ArrayReply:
n, err := parseArrayLen(line) n, err := parseArrayLen(line)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return m(p, n) return m(r, n)
} }
return nil, fmt.Errorf("redis: can't parse %.100q", line) return nil, fmt.Errorf("redis: can't parse %.100q", line)
} }
func (p *Reader) ReadIntReply() (int64, error) { func (r *Reader) ReadIntReply() (int64, error) {
line, err := p.ReadLine() line, err := r.ReadLine()
if err != nil { if err != nil {
return 0, err return 0, err
} }
@ -111,8 +111,8 @@ func (p *Reader) ReadIntReply() (int64, error) {
} }
} }
func (p *Reader) ReadTmpBytesReply() ([]byte, error) { func (r *Reader) ReadTmpBytesReply() ([]byte, error) {
line, err := p.ReadLine() line, err := r.ReadLine()
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -120,7 +120,7 @@ func (p *Reader) ReadTmpBytesReply() ([]byte, error) {
case ErrorReply: case ErrorReply:
return nil, ParseErrorReply(line) return nil, ParseErrorReply(line)
case StringReply: case StringReply:
return p.readTmpBytesValue(line) return r.readTmpBytesValue(line)
case StatusReply: case StatusReply:
return parseStatusValue(line), nil return parseStatusValue(line), nil
default: default:
@ -138,24 +138,24 @@ func (r *Reader) ReadBytesReply() ([]byte, error) {
return cp, nil return cp, nil
} }
func (p *Reader) ReadStringReply() (string, error) { func (r *Reader) ReadStringReply() (string, error) {
b, err := p.ReadTmpBytesReply() b, err := r.ReadTmpBytesReply()
if err != nil { if err != nil {
return "", err return "", err
} }
return string(b), nil return string(b), nil
} }
func (p *Reader) ReadFloatReply() (float64, error) { func (r *Reader) ReadFloatReply() (float64, error) {
b, err := p.ReadTmpBytesReply() b, err := r.ReadTmpBytesReply()
if err != nil { if err != nil {
return 0, err return 0, err
} }
return parseFloat(b, 64) return parseFloat(b, 64)
} }
func (p *Reader) ReadArrayReply(m MultiBulkParse) (interface{}, error) { func (r *Reader) ReadArrayReply(m MultiBulkParse) (interface{}, error) {
line, err := p.ReadLine() line, err := r.ReadLine()
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -167,14 +167,14 @@ func (p *Reader) ReadArrayReply(m MultiBulkParse) (interface{}, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
return m(p, n) return m(r, n)
default: default:
return nil, fmt.Errorf("redis: can't parse array reply: %.100q", line) return nil, fmt.Errorf("redis: can't parse array reply: %.100q", line)
} }
} }
func (p *Reader) ReadArrayLen() (int64, error) { func (r *Reader) ReadArrayLen() (int64, error) {
line, err := p.ReadLine() line, err := r.ReadLine()
if err != nil { if err != nil {
return 0, err return 0, err
} }
@ -188,8 +188,8 @@ func (p *Reader) ReadArrayLen() (int64, error) {
} }
} }
func (p *Reader) ReadScanReply() ([]string, uint64, error) { func (r *Reader) ReadScanReply() ([]string, uint64, error) {
n, err := p.ReadArrayLen() n, err := r.ReadArrayLen()
if err != nil { if err != nil {
return nil, 0, err return nil, 0, err
} }
@ -202,14 +202,14 @@ func (p *Reader) ReadScanReply() ([]string, uint64, error) {
return nil, 0, err return nil, 0, err
} }
n, err = p.ReadArrayLen() n, err = r.ReadArrayLen()
if err != nil { if err != nil {
return nil, 0, err return nil, 0, err
} }
keys := make([]string, n) keys := make([]string, n)
for i := int64(0); i < n; i++ { for i := int64(0); i < n; i++ {
key, err := p.ReadStringReply() key, err := r.ReadStringReply()
if err != nil { if err != nil {
return nil, 0, err return nil, 0, err
} }
@ -219,7 +219,7 @@ func (p *Reader) ReadScanReply() ([]string, uint64, error) {
return keys, cursor, err return keys, cursor, err
} }
func (p *Reader) readTmpBytesValue(line []byte) ([]byte, error) { func (r *Reader) readTmpBytesValue(line []byte) ([]byte, error) {
if isNilReply(line) { if isNilReply(line) {
return nil, internal.Nil return nil, internal.Nil
} }
@ -229,7 +229,7 @@ func (p *Reader) readTmpBytesValue(line []byte) ([]byte, error) {
return nil, err return nil, err
} }
b, err := p.ReadN(replyLen + 2) b, err := r.ReadN(replyLen + 2)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -127,7 +127,7 @@ func (c *PubSub) Close() error {
return nil return nil
} }
// Subscribes the client to the specified channels. It returns // Subscribe the client to the specified channels. It returns
// empty subscription if there are no channels. // empty subscription if there are no channels.
func (c *PubSub) Subscribe(channels ...string) error { func (c *PubSub) Subscribe(channels ...string) error {
c.mu.Lock() c.mu.Lock()
@ -137,7 +137,7 @@ func (c *PubSub) Subscribe(channels ...string) error {
return err return err
} }
// Subscribes the client to the given patterns. It returns // PSubscribe the client to the given patterns. It returns
// empty subscription if there are no patterns. // empty subscription if there are no patterns.
func (c *PubSub) PSubscribe(patterns ...string) error { func (c *PubSub) PSubscribe(patterns ...string) error {
c.mu.Lock() c.mu.Lock()
@ -147,7 +147,7 @@ func (c *PubSub) PSubscribe(patterns ...string) error {
return err return err
} }
// Unsubscribes the client from the given channels, or from all of // Unsubscribe the client from the given channels, or from all of
// them if none is given. // them if none is given.
func (c *PubSub) Unsubscribe(channels ...string) error { func (c *PubSub) Unsubscribe(channels ...string) error {
c.mu.Lock() c.mu.Lock()
@ -157,7 +157,7 @@ func (c *PubSub) Unsubscribe(channels ...string) error {
return err return err
} }
// Unsubscribes the client from the given patterns, or from all of // PUnsubscribe the client from the given patterns, or from all of
// them if none is given. // them if none is given.
func (c *PubSub) PUnsubscribe(patterns ...string) error { func (c *PubSub) PUnsubscribe(patterns ...string) error {
c.mu.Lock() c.mu.Lock()
@ -196,7 +196,7 @@ func (c *PubSub) Ping(payload ...string) error {
return err return err
} }
// Message received after a successful subscription to channel. // Subscription received after a successful subscription to channel.
type Subscription struct { type Subscription struct {
// Can be "subscribe", "unsubscribe", "psubscribe" or "punsubscribe". // Can be "subscribe", "unsubscribe", "psubscribe" or "punsubscribe".
Kind string Kind string

View File

@ -11,7 +11,7 @@ import (
"github.com/go-redis/redis/internal/proto" "github.com/go-redis/redis/internal/proto"
) )
// Redis nil reply returned when key does not exist. // Nil reply redis returned when key does not exist.
const Nil = internal.Nil const Nil = internal.Nil
func init() { func init() {
@ -172,9 +172,9 @@ func (c *baseClient) retryBackoff(attempt int) time.Duration {
func (c *baseClient) cmdTimeout(cmd Cmder) time.Duration { func (c *baseClient) cmdTimeout(cmd Cmder) time.Duration {
if timeout := cmd.readTimeout(); timeout != nil { if timeout := cmd.readTimeout(); timeout != nil {
return *timeout return *timeout
} else {
return c.opt.ReadTimeout
} }
return c.opt.ReadTimeout
} }
// Close closes the client, releasing any open resources. // Close closes the client, releasing any open resources.

4
tx.go
View File

@ -5,7 +5,7 @@ import (
"github.com/go-redis/redis/internal/pool" "github.com/go-redis/redis/internal/pool"
) )
// Redis transaction failed. // TxFailedErr transaction redis failed.
const TxFailedErr = internal.RedisError("redis: transaction failed") const TxFailedErr = internal.RedisError("redis: transaction failed")
// Tx implements Redis transactions as described in // Tx implements Redis transactions as described in
@ -42,7 +42,7 @@ func (c *Client) Watch(fn func(*Tx) error, keys ...string) error {
return err return err
} }
// close closes the transaction, releasing any open resources. // Close closes the transaction, releasing any open resources.
func (c *Tx) Close() error { func (c *Tx) Close() error {
_ = c.Unwatch().Err() _ = c.Unwatch().Err()
return c.baseClient.Close() return c.baseClient.Close()