Skip to content

Commit

Permalink
Addressing issue #3 - fixing golint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
stephensearles committed Dec 14, 2014
1 parent 8194b36 commit 3ef3655
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 88 deletions.
6 changes: 3 additions & 3 deletions pool.go
Expand Up @@ -39,7 +39,7 @@ func (p *Pool) put(c *Conn) error {
return c.conn.Close()
}
p.pool.Put(c)
p.idle += 1
p.idle++
return nil
}

Expand All @@ -50,7 +50,7 @@ func (p *Pool) Conn() (*Conn, error) {
if client == nil || !ok {
return p.newConn()
}
p.idle -= 1
p.idle--
return client, nil
}

Expand All @@ -67,7 +67,7 @@ func (p *Pool) newConn() (c *Conn, err error) {

if p.Password != "" {
c.RawCmd("AUTH", p.Password)
if r := c.Resp(); r.Type() == resp.Error {
if r := c.Resp(); r.Type() == resp.ErrorType {
return nil, r.Error()
}
}
Expand Down
10 changes: 5 additions & 5 deletions pubsub.go
Expand Up @@ -149,12 +149,12 @@ func (p *sub) watch() {

func (p *sub) read() {
switch p.conn.Resp().Type() {
case resp.Unknown: // do nothing, we haven't read yet
case resp.Error:
case resp.UnknownType: // do nothing, we haven't read yet
case resp.ErrorType:
p.conn.Resp().Error()
case resp.Invalid:
case resp.InvalidType:
panic("redis pubsub: invalid message received")
case resp.Array:
case resp.ArrayType:
arr, _ := p.conn.Resp().Array()
p.receive(arr)
default:
Expand All @@ -163,7 +163,7 @@ func (p *sub) read() {
}
}

func (p *sub) receive(r *resp.RESPArray) {
func (p *sub) receive(r *resp.Array) {
first := r.Next()

rd, err := first.BulkString()
Expand Down
11 changes: 5 additions & 6 deletions redis.go
@@ -1,4 +1,4 @@
// Redis implements basic connections and pooling to redis servers.
// Package redis implements basic connections and pooling to redis servers.
//
// This package operates with streams of data (io.Reader). As necessry
// the package will cache data locally before read by clients, for example
Expand Down Expand Up @@ -67,7 +67,7 @@ func (c *Conn) RawCmd(command string, args ...string) error {
// only allows one open command at a time and will block callers to prevent jumbled queues.
func (c *Conn) Command(command string, args int) (*Cmd, error) {
c.commandLock.Lock()
c.openCommands += 1
c.openCommands++

fmt.Fprintf(c.conn, "*%d\r\n", args+1)
cmd := &Cmd{c.conn, c}
Expand All @@ -80,20 +80,19 @@ func (c *Conn) Command(command string, args int) (*Cmd, error) {
func (c *Conn) Close() error {
if c.whence != nil {
return c.whence.put(c)
} else {
return c.Destroy()
}
return c.Destroy()
}

// Destory always destroys the connection.
// Destroy always destroys the connection.
func (c *Conn) Destroy() error {
return c.conn.Close()
}

// Resp reads a RESP from the connection
func (c *Conn) Resp() *resp.RESP {
defer func() {
c.openCommands -= 1
c.openCommands--
}()
return c.reply
}
Expand Down
10 changes: 5 additions & 5 deletions redis/arglexer.go
Expand Up @@ -16,7 +16,7 @@ type argLexer struct {
}

func (l *argLexer) getargs() []string {
args := make([]string, 0)
var args []string
for arg := range l.args {
args = append(args, arg)
}
Expand All @@ -32,11 +32,11 @@ func newLexer(argText string) *argLexer {
return a
}

func (a *argLexer) run() {
func (l *argLexer) run() {
for state := lexArg; state != nil; {
state = state(a)
state = state(l)
}
close(a.args)
close(l.args)
}

func lexArg(l *argLexer) stateFn {
Expand Down Expand Up @@ -121,7 +121,7 @@ func (l *argLexer) acceptNonQuote() {
preceedingSlashes := 0
for r := l.next(); (r != '"' || preceedingSlashes%2 == 1) && r != eof; r = l.next() {
if r == '\\' {
preceedingSlashes += 1
preceedingSlashes++
} else {
preceedingSlashes = 0
}
Expand Down

0 comments on commit 3ef3655

Please sign in to comment.