Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go vet, golint, fmt fix #138

Merged
merged 1 commit into from
May 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ func coerce(v interface{}, typ reflect.Type) (reflect.Value, error) {
v, err = coerceBackoffStrategy(v)
default:
v = nil
err = errors.New(fmt.Sprintf("invalid type %s", typ.String()))
err = fmt.Errorf("invalid type %s", typ.String())
}
return valueTypeCoerce(v, typ), err
}
Expand Down Expand Up @@ -576,10 +576,8 @@ func coerceString(v interface{}) (string, error) {
return fmt.Sprintf("%d", v), nil
case float32, float64:
return fmt.Sprintf("%f", v), nil
default:
return fmt.Sprintf("%s", v), nil
}
return "", errors.New("invalid value type")
return fmt.Sprintf("%s", v), nil
}

func coerceDuration(v interface{}) (time.Duration, error) {
Expand Down
3 changes: 2 additions & 1 deletion conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,8 @@ func (c *Conn) auth(secret string) error {
return err
}

c.log(LogLevelInfo, "Auth accepted. Identity: %q %s Permissions: %d", resp.Identity, resp.IdentityUrl, resp.PermissionCount)
c.log(LogLevelInfo, "Auth accepted. Identity: %q %s Permissions: %d",
resp.Identity, resp.IdentityUrl, resp.PermissionCount)

return nil
}
Expand Down
10 changes: 5 additions & 5 deletions consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ func (r *Consumer) ConnectToNSQLookupd(addr string) error {
return nil
}

// ConnectToNSQLookupd adds multiple nsqlookupd address to the list for this Consumer instance.
// ConnectToNSQLookupds adds multiple nsqlookupd address to the list for this Consumer instance.
//
// If adding the first address it initiates an HTTP request to discover nsqd
// producers for the configured topic.
Expand Down Expand Up @@ -462,7 +462,7 @@ func (r *Consumer) queryLookupd() {
return
}

nsqdAddrs := make([]string, 0)
var nsqdAddrs []string
for _, producer := range data.Producers {
broadcastAddress := producer.BroadcastAddress
port := producer.TCPPort
Expand All @@ -482,7 +482,7 @@ func (r *Consumer) queryLookupd() {
}
}

// ConnectToNSQD takes multiple nsqd addresses to connect directly to.
// ConnectToNSQDs takes multiple nsqd addresses to connect directly to.
//
// It is recommended to use ConnectToNSQLookupd so that topics are discovered
// automatically. This method is useful when you want to connect to local instance.
Expand Down Expand Up @@ -622,7 +622,7 @@ func (r *Consumer) DisconnectFromNSQLookupd(addr string) error {
}

if len(r.lookupdHTTPAddrs) == 1 {
return errors.New(fmt.Sprintf("cannot disconnect from only remaining nsqlookupd HTTP address %s", addr))
return fmt.Errorf("cannot disconnect from only remaining nsqlookupd HTTP address %s", addr)
}

r.lookupdHTTPAddrs = append(r.lookupdHTTPAddrs[:idx], r.lookupdHTTPAddrs[idx+1:]...)
Expand Down Expand Up @@ -732,7 +732,7 @@ func (r *Consumer) onConnClose(c *Conn) {
// try to reconnect after a bit
go func(addr string) {
for {
r.log(LogLevelInfo, "(%s) re-connecting in %.04f seconds...", addr, r.config.LookupdPollInterval)
r.log(LogLevelInfo, "(%s) re-connecting in %s", addr, r.config.LookupdPollInterval)
time.Sleep(r.config.LookupdPollInterval)
if atomic.LoadInt32(&r.stopFlag) == 1 {
break
Expand Down
1 change: 1 addition & 0 deletions delegates.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type logger interface {
// LogLevel specifies the severity of a given log message
type LogLevel int

// Log levels
const (
LogLevelDebug LogLevel = iota
LogLevelInfo
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// nsq is the official Go package for NSQ (http://nsq.io/)
// Package nsq is the official Go package for NSQ (http://nsq.io/)
//
// It provides high-level Consumer and Producer types as well as low-level
// functions to communicate over the NSQ protocol
Expand Down