From 5ea8ad46d66517a6aa1dd804b50d4ad57bad31cb Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Wed, 18 Jun 2014 16:47:21 +0300 Subject: [PATCH] Fix import path. --- .travis.yml | 3 +-- command.go | 30 ++++++++++++++++-------------- parser.go | 36 ++++++++++++++---------------------- pool.go | 4 ++-- 4 files changed, 33 insertions(+), 40 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5fc004e2..b80df9d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,13 +4,12 @@ services: - redis-server go: - - 1.0 - 1.1 - 1.2 - tip install: - - go get github.com/vmihailenco/bufio + - go get gopkg.in/bufio.v1 - go get github.com/golang/glog - go get launchpad.net/gocheck - go get gopkg.in/redis.v1 diff --git a/command.go b/command.go index ffdd1a3a..0c8992c0 100644 --- a/command.go +++ b/command.go @@ -5,6 +5,8 @@ import ( "strconv" "strings" "time" + + "gopkg.in/bufio.v1" ) var ( @@ -25,7 +27,7 @@ var ( type Cmder interface { args() []string - parseReply(reader) error + parseReply(*bufio.Reader) error setErr(error) writeTimeout() *time.Duration @@ -126,7 +128,7 @@ func (cmd *Cmd) String() string { return cmdString(cmd, cmd.val) } -func (cmd *Cmd) parseReply(rd reader) error { +func (cmd *Cmd) parseReply(rd *bufio.Reader) error { cmd.val, cmd.err = parseReply(rd, parseSlice) return cmd.err } @@ -157,7 +159,7 @@ func (cmd *SliceCmd) String() string { return cmdString(cmd, cmd.val) } -func (cmd *SliceCmd) parseReply(rd reader) error { +func (cmd *SliceCmd) parseReply(rd *bufio.Reader) error { v, err := parseReply(rd, parseSlice) if err != nil { cmd.err = err @@ -193,7 +195,7 @@ func (cmd *StatusCmd) String() string { return cmdString(cmd, cmd.val) } -func (cmd *StatusCmd) parseReply(rd reader) error { +func (cmd *StatusCmd) parseReply(rd *bufio.Reader) error { v, err := parseReply(rd, nil) if err != nil { cmd.err = err @@ -229,7 +231,7 @@ func (cmd *IntCmd) String() string { return cmdString(cmd, cmd.val) } -func (cmd *IntCmd) parseReply(rd reader) error { +func (cmd *IntCmd) parseReply(rd *bufio.Reader) error { v, err := parseReply(rd, nil) if err != nil { cmd.err = err @@ -267,7 +269,7 @@ func (cmd *DurationCmd) String() string { return cmdString(cmd, cmd.val) } -func (cmd *DurationCmd) parseReply(rd reader) error { +func (cmd *DurationCmd) parseReply(rd *bufio.Reader) error { v, err := parseReply(rd, nil) if err != nil { cmd.err = err @@ -303,7 +305,7 @@ func (cmd *BoolCmd) String() string { return cmdString(cmd, cmd.val) } -func (cmd *BoolCmd) parseReply(rd reader) error { +func (cmd *BoolCmd) parseReply(rd *bufio.Reader) error { v, err := parseReply(rd, nil) if err != nil { cmd.err = err @@ -339,7 +341,7 @@ func (cmd *StringCmd) String() string { return cmdString(cmd, cmd.val) } -func (cmd *StringCmd) parseReply(rd reader) error { +func (cmd *StringCmd) parseReply(rd *bufio.Reader) error { v, err := parseReply(rd, nil) if err != nil { cmd.err = err @@ -371,7 +373,7 @@ func (cmd *FloatCmd) String() string { return cmdString(cmd, cmd.val) } -func (cmd *FloatCmd) parseReply(rd reader) error { +func (cmd *FloatCmd) parseReply(rd *bufio.Reader) error { v, err := parseReply(rd, nil) if err != nil { cmd.err = err @@ -407,7 +409,7 @@ func (cmd *StringSliceCmd) String() string { return cmdString(cmd, cmd.val) } -func (cmd *StringSliceCmd) parseReply(rd reader) error { +func (cmd *StringSliceCmd) parseReply(rd *bufio.Reader) error { v, err := parseReply(rd, parseStringSlice) if err != nil { cmd.err = err @@ -443,7 +445,7 @@ func (cmd *BoolSliceCmd) String() string { return cmdString(cmd, cmd.val) } -func (cmd *BoolSliceCmd) parseReply(rd reader) error { +func (cmd *BoolSliceCmd) parseReply(rd *bufio.Reader) error { v, err := parseReply(rd, parseBoolSlice) if err != nil { cmd.err = err @@ -479,7 +481,7 @@ func (cmd *StringStringMapCmd) String() string { return cmdString(cmd, cmd.val) } -func (cmd *StringStringMapCmd) parseReply(rd reader) error { +func (cmd *StringStringMapCmd) parseReply(rd *bufio.Reader) error { v, err := parseReply(rd, parseStringStringMap) if err != nil { cmd.err = err @@ -515,7 +517,7 @@ func (cmd *StringFloatMapCmd) String() string { return cmdString(cmd, cmd.val) } -func (cmd *StringFloatMapCmd) parseReply(rd reader) error { +func (cmd *StringFloatMapCmd) parseReply(rd *bufio.Reader) error { v, err := parseReply(rd, parseStringFloatMap) if err != nil { cmd.err = err @@ -552,7 +554,7 @@ func (cmd *ScanCmd) String() string { return cmdString(cmd, cmd.keys) } -func (cmd *ScanCmd) parseReply(rd reader) error { +func (cmd *ScanCmd) parseReply(rd *bufio.Reader) error { vi, err := parseReply(rd, parseSlice) if err != nil { cmd.err = err diff --git a/parser.go b/parser.go index a1a0f55a..fdaea65f 100644 --- a/parser.go +++ b/parser.go @@ -5,10 +5,10 @@ import ( "fmt" "strconv" - "github.com/vmihailenco/bufio" + "gopkg.in/bufio.v1" ) -type multiBulkParser func(rd reader, n int64) (interface{}, error) +type multiBulkParser func(rd *bufio.Reader, n int64) (interface{}, error) var ( errReaderTooSmall = errors.New("redis: reader is too small") @@ -33,15 +33,7 @@ func appendCmd(buf []byte, args []string) []byte { //------------------------------------------------------------------------------ -type reader interface { - ReadLine() ([]byte, bool, error) - Read([]byte) (int, error) - ReadN(n int) ([]byte, error) - Buffered() int - Peek(int) ([]byte, error) -} - -func readLine(rd reader) ([]byte, error) { +func readLine(rd *bufio.Reader) ([]byte, error) { line, isPrefix, err := rd.ReadLine() if err != nil { return line, err @@ -52,12 +44,12 @@ func readLine(rd reader) ([]byte, error) { return line, nil } -func readN(rd reader, n int) ([]byte, error) { +func readN(rd *bufio.Reader, n int) ([]byte, error) { b, err := rd.ReadN(n) if err == bufio.ErrBufferFull { - newB := make([]byte, n) - r := copy(newB, b) - b = newB + tmp := make([]byte, n) + r := copy(tmp, b) + b = tmp for { nn, err := rd.Read(b[r:]) @@ -78,7 +70,7 @@ func readN(rd reader, n int) ([]byte, error) { //------------------------------------------------------------------------------ -func parseReq(rd reader) ([]string, error) { +func parseReq(rd *bufio.Reader) ([]string, error) { line, err := readLine(rd) if err != nil { return nil, err @@ -118,7 +110,7 @@ func parseReq(rd reader) ([]string, error) { //------------------------------------------------------------------------------ -func parseReply(rd reader, p multiBulkParser) (interface{}, error) { +func parseReply(rd *bufio.Reader, p multiBulkParser) (interface{}, error) { line, err := readLine(rd) if err != nil { return nil, err @@ -166,7 +158,7 @@ func parseReply(rd reader, p multiBulkParser) (interface{}, error) { return nil, fmt.Errorf("redis: can't parse %q", line) } -func parseSlice(rd reader, n int64) (interface{}, error) { +func parseSlice(rd *bufio.Reader, n int64) (interface{}, error) { vals := make([]interface{}, 0, n) for i := int64(0); i < n; i++ { v, err := parseReply(rd, parseSlice) @@ -181,7 +173,7 @@ func parseSlice(rd reader, n int64) (interface{}, error) { return vals, nil } -func parseStringSlice(rd reader, n int64) (interface{}, error) { +func parseStringSlice(rd *bufio.Reader, n int64) (interface{}, error) { vals := make([]string, 0, n) for i := int64(0); i < n; i++ { vi, err := parseReply(rd, nil) @@ -197,7 +189,7 @@ func parseStringSlice(rd reader, n int64) (interface{}, error) { return vals, nil } -func parseBoolSlice(rd reader, n int64) (interface{}, error) { +func parseBoolSlice(rd *bufio.Reader, n int64) (interface{}, error) { vals := make([]bool, 0, n) for i := int64(0); i < n; i++ { vi, err := parseReply(rd, nil) @@ -213,7 +205,7 @@ func parseBoolSlice(rd reader, n int64) (interface{}, error) { return vals, nil } -func parseStringStringMap(rd reader, n int64) (interface{}, error) { +func parseStringStringMap(rd *bufio.Reader, n int64) (interface{}, error) { m := make(map[string]string, n/2) for i := int64(0); i < n; i += 2 { keyI, err := parseReply(rd, nil) @@ -239,7 +231,7 @@ func parseStringStringMap(rd reader, n int64) (interface{}, error) { return m, nil } -func parseStringFloatMap(rd reader, n int64) (interface{}, error) { +func parseStringFloatMap(rd *bufio.Reader, n int64) (interface{}, error) { m := make(map[string]float64, n/2) for i := int64(0); i < n; i += 2 { keyI, err := parseReply(rd, nil) diff --git a/pool.go b/pool.go index a7ae796e..4ecb2282 100644 --- a/pool.go +++ b/pool.go @@ -8,7 +8,7 @@ import ( "time" "github.com/golang/glog" - "github.com/vmihailenco/bufio" + "gopkg.in/bufio.v1" ) var ( @@ -34,7 +34,7 @@ type pool interface { type conn struct { netcn net.Conn - rd reader + rd *bufio.Reader inUse bool usedAt time.Time