diff --git a/.travis.yml b/.travis.yml index 5d087ec5..1ef636f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ install: - go get github.com/nats-io/jwt - go get github.com/mattn/goveralls - go get github.com/wadey/gocovmerge -- go get -u honnef.co/go/tools/cmd/megacheck +- go get -u honnef.co/go/tools/cmd/staticcheck - go get -u github.com/client9/misspell/cmd/misspell before_script: - EXCLUDE_VENDOR=$(go list ./... | grep -v "/vendor/") @@ -16,7 +16,7 @@ before_script: - $(exit $(go fmt $EXCLUDE_VENDOR | wc -l)) - go vet $EXCLUDE_VENDOR - misspell -error -locale US . -- megacheck $EXCLUDE_VENDOR +- staticcheck $EXCLUDE_VENDOR - if [[ "$TRAVIS_GO_VERSION" =~ 1.11 ]] && [ "$TRAVIS_TAG" != "" ]; then ./scripts/cross_compile.sh $TRAVIS_TAG; fi script: - go test -i $EXCLUDE_VENDOR diff --git a/conf/parse.go b/conf/parse.go index a6684f2c..c08fc0d6 100644 --- a/conf/parse.go +++ b/conf/parse.go @@ -84,6 +84,7 @@ func ParseFile(fp string) (map[string]interface{}, error) { return p.mapping, nil } +// ParseFileWithChecks is equivalent to ParseFile but runs in pedantic mode. func ParseFileWithChecks(fp string) (map[string]interface{}, error) { data, err := ioutil.ReadFile(fp) if err != nil { @@ -240,9 +241,9 @@ func (p *parser) processItem(it item, fp string) error { if err != nil { if e, ok := err.(*strconv.NumError); ok && e.Err == strconv.ErrRange { - return fmt.Errorf("Integer '%s' is out of the range.", it.val) + return fmt.Errorf("integer '%s' is out of the range", it.val) } - return fmt.Errorf("Expected integer, but got '%s'.", it.val) + return fmt.Errorf("expected integer, but got '%s'", it.val) } // Process a suffix suffix := strings.ToLower(strings.TrimSpace(it.val[lastDigit:])) @@ -268,9 +269,9 @@ func (p *parser) processItem(it item, fp string) error { if err != nil { if e, ok := err.(*strconv.NumError); ok && e.Err == strconv.ErrRange { - return fmt.Errorf("Float '%s' is out of the range.", it.val) + return fmt.Errorf("float '%s' is out of the range", it.val) } - return fmt.Errorf("Expected float, but got '%s'.", it.val) + return fmt.Errorf("expected float, but got '%s'", it.val) } setValue(it, num) case itemBool: @@ -280,14 +281,14 @@ func (p *parser) processItem(it item, fp string) error { case "false", "no", "off": setValue(it, false) default: - return fmt.Errorf("Expected boolean value, but got '%s'.", it.val) + return fmt.Errorf("expected boolean value, but got '%s'", it.val) } case itemDatetime: dt, err := time.Parse("2006-01-02T15:04:05Z", it.val) if err != nil { return fmt.Errorf( - "Expected Zulu formatted DateTime, but got '%s'.", it.val) + "expected Zulu formatted DateTime, but got '%s'", it.val) } setValue(it, dt) case itemArrayStart: @@ -314,7 +315,7 @@ func (p *parser) processItem(it item, fp string) error { p.setValue(value) } } else { - return fmt.Errorf("Variable reference for '%s' on line %d can not be found.", + return fmt.Errorf("variable reference for '%s' on line %d can not be found", it.val, it.line) } case itemInclude: @@ -328,7 +329,7 @@ func (p *parser) processItem(it item, fp string) error { m, err = ParseFile(filepath.Join(p.fp, it.val)) } if err != nil { - return fmt.Errorf("Error parsing include file '%s', %v.", it.val, err) + return fmt.Errorf("error parsing include file '%s', %v", it.val, err) } for k, v := range m { p.pushKey(k) @@ -364,7 +365,7 @@ func (p *parser) lookupVariable(varReference string) (interface{}, bool) { } // Loop through contexts currently on the stack. - for i := len(p.ctxs) - 1; i >= 0; i -= 1 { + for i := len(p.ctxs) - 1; i >= 0; i-- { ctx := p.ctxs[i] // Process if it is a map context if m, ok := ctx.(map[string]interface{}); ok { diff --git a/conf/parse_test.go b/conf/parse_test.go index 4b781a9e..64e4c6f5 100644 --- a/conf/parse_test.go +++ b/conf/parse_test.go @@ -86,7 +86,7 @@ func TestMissingVariable(t *testing.T) { if err == nil { t.Fatalf("Expected an error for a missing variable, got none") } - if !strings.HasPrefix(err.Error(), "Variable reference") { + if !strings.HasPrefix(err.Error(), "variable reference") { t.Fatalf("Wanted a variable reference err, got %q\n", err) } } diff --git a/server/accounts.go b/server/accounts.go index 32e21117..02e79263 100644 --- a/server/accounts.go +++ b/server/accounts.go @@ -1038,11 +1038,11 @@ func (ur *URLAccResolver) Fetch(name string) (string, error) { url := ur.url + name resp, err := ur.c.Get(url) if err != nil { - return _EMPTY_, fmt.Errorf("Could not fetch <%q>: %v", url, err) + return _EMPTY_, fmt.Errorf("could not fetch <%q>: %v", url, err) } else if resp == nil { - return _EMPTY_, fmt.Errorf("Could not fetch <%q>: no response", url) + return _EMPTY_, fmt.Errorf("could not fetch <%q>: no response", url) } else if resp.StatusCode != http.StatusOK { - return _EMPTY_, fmt.Errorf("Could not fetch <%q>: %v", url, resp.Status) + return _EMPTY_, fmt.Errorf("could not fetch <%q>: %v", url, resp.Status) } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) diff --git a/server/client.go b/server/client.go index 098c4bdc..37e15a2a 100644 --- a/server/client.go +++ b/server/client.go @@ -1078,16 +1078,14 @@ func (c *client) processConnect(arg []byte) error { c.sendErr("Account Not Found") return err } else if accountNew && acc != nil { - c.Errorf(ErrAccountExists.Error()) - c.sendErr(ErrAccountExists.Error()) + c.sendErrAndErr(ErrAccountExists.Error()) return ErrAccountExists } } else { // We can create this one on the fly. acc, wasNew = srv.LookupOrRegisterAccount(account) if accountNew && !wasNew { - c.Errorf(ErrAccountExists.Error()) - c.sendErr(ErrAccountExists.Error()) + c.sendErrAndErr(ErrAccountExists.Error()) return ErrAccountExists } } diff --git a/server/config_check_test.go b/server/config_check_test.go index 3b36cc39..982bf71a 100644 --- a/server/config_check_test.go +++ b/server/config_check_test.go @@ -356,7 +356,7 @@ func TestConfigCheck(t *testing.T) { ] } `, - err: errors.New(`Unrecognized curve preference CurveP5210000`), + err: errors.New(`unrecognized curve preference CurveP5210000`), errorLine: 4, errorPos: 5, }, @@ -1032,7 +1032,7 @@ func TestConfigCheck(t *testing.T) { } } `, - err: errors.New(`Subject "foo..bar" is not a valid subject`), + err: errors.New(`subject "foo..bar" is not a valid subject`), errorLine: 5, errorPos: 9, }, @@ -1043,7 +1043,7 @@ func TestConfigCheck(t *testing.T) { listen = "0.0.0.0:XXXX" } `, - err: errors.New(`Could not parse port "XXXX"`), + err: errors.New(`could not parse port "XXXX"`), errorLine: 3, errorPos: 5, }, diff --git a/server/errors.go b/server/errors.go index c8e46c89..da9fe601 100644 --- a/server/errors.go +++ b/server/errors.go @@ -20,91 +20,91 @@ import ( var ( // ErrConnectionClosed represents an error condition on a closed connection. - ErrConnectionClosed = errors.New("Connection Closed") + ErrConnectionClosed = errors.New("connection closed") // ErrAuthentication represents an error condition on failed authentication. - ErrAuthentication = errors.New("Authentication Error") + ErrAuthentication = errors.New("authentication error") // ErrAuthTimeout represents an error condition on failed authorization due to timeout. - ErrAuthTimeout = errors.New("Authentication Timeout") + ErrAuthTimeout = errors.New("authentication timeout") // ErrAuthExpired represents an expired authorization due to timeout. - ErrAuthExpired = errors.New("Authentication Expired") + ErrAuthExpired = errors.New("authentication expired") // ErrMaxPayload represents an error condition when the payload is too big. - ErrMaxPayload = errors.New("Maximum Payload Exceeded") + ErrMaxPayload = errors.New("maximum payload exceeded") // ErrMaxControlLine represents an error condition when the control line is too big. - ErrMaxControlLine = errors.New("Maximum Control Line Exceeded") + ErrMaxControlLine = errors.New("maximum control line exceeded") // ErrReservedPublishSubject represents an error condition when sending to a reserved subject, e.g. _SYS.> - ErrReservedPublishSubject = errors.New("Reserved Internal Subject") + ErrReservedPublishSubject = errors.New("reserved internal subject") // ErrBadClientProtocol signals a client requested an invalud client protocol. - ErrBadClientProtocol = errors.New("Invalid Client Protocol") + ErrBadClientProtocol = errors.New("invalid client protocol") // ErrTooManyConnections signals a client that the maximum number of connections supported by the // server has been reached. - ErrTooManyConnections = errors.New("Maximum Connections Exceeded") + ErrTooManyConnections = errors.New("maximum connections exceeded") // ErrTooManyAccountConnections signals that an acount has reached its maximum number of active // connections. - ErrTooManyAccountConnections = errors.New("Maximum Account Active Connections Exceeded") + ErrTooManyAccountConnections = errors.New("maximum account active connections exceeded") // ErrTooManySubs signals a client that the maximum number of subscriptions per connection // has been reached. - ErrTooManySubs = errors.New("Maximum Subscriptions Exceeded") + ErrTooManySubs = errors.New("maximum subscriptions exceeded") // ErrClientConnectedToRoutePort represents an error condition when a client // attempted to connect to the route listen port. - ErrClientConnectedToRoutePort = errors.New("Attempted To Connect To Route Port") + ErrClientConnectedToRoutePort = errors.New("attempted to connect to route port") // ErrAccountExists is returned when an account is attempted to be registered // but already exists. - ErrAccountExists = errors.New("Account Exists") + ErrAccountExists = errors.New("account exists") // ErrBadAccount represents a malformed or incorrect account. - ErrBadAccount = errors.New("Bad Account") + ErrBadAccount = errors.New("bad account") // ErrReservedAccount represents a reserved account that can not be created. - ErrReservedAccount = errors.New("Reserved Account") + ErrReservedAccount = errors.New("reserved account") // ErrMissingAccount is returned when an account does not exist. - ErrMissingAccount = errors.New("Account Missing") + ErrMissingAccount = errors.New("account missing") // ErrAccountValidation is returned when an account has failed validation. - ErrAccountValidation = errors.New("Account Validation Failed") + ErrAccountValidation = errors.New("account validation failed") // ErrAccountExpired is returned when an account has expired. - ErrAccountExpired = errors.New("Account Expired") + ErrAccountExpired = errors.New("account expired") // ErrNoAccountResolver is returned when we attempt an update but do not have an account resolver. - ErrNoAccountResolver = errors.New("Account Resolver Missing") + ErrNoAccountResolver = errors.New("account resolver missing") // ErrAccountResolverUpdateTooSoon is returned when we attempt an update too soon to last request. - ErrAccountResolverUpdateTooSoon = errors.New("Account Resolver Update Too Soon") + ErrAccountResolverUpdateTooSoon = errors.New("account resolver update too soon") // ErrAccountResolverSameClaims is returned when same claims have been fetched. - ErrAccountResolverSameClaims = errors.New("Account Resolver No New Claims") + ErrAccountResolverSameClaims = errors.New("account resolver no new claims") // ErrStreamImportAuthorization is returned when a stream import is not authorized. - ErrStreamImportAuthorization = errors.New("Stream Import Not Authorized") + ErrStreamImportAuthorization = errors.New("stream import not authorized") // ErrServiceImportAuthorization is returned when a service import is not authorized. - ErrServiceImportAuthorization = errors.New("Service Import Not Authorized") + ErrServiceImportAuthorization = errors.New("service import not authorized") // ErrClientOrRouteConnectedToGatewayPort represents an error condition when // a client or route attempted to connect to the Gateway port. - ErrClientOrRouteConnectedToGatewayPort = errors.New("Attempted To Connect To Gateway Port") + ErrClientOrRouteConnectedToGatewayPort = errors.New("attempted to connect to gateway port") // ErrWrongGateway represents an error condition when a server receives a connect // request from a remote Gateway with a destination name that does not match the server's // Gateway's name. - ErrWrongGateway = errors.New("Wrong Gateway") + ErrWrongGateway = errors.New("wrong gateway") // ErrNoSysAccount is returned when an attempt to publish or subscribe is made // when there is no internal system account defined. - ErrNoSysAccount = errors.New("System Account Not Setup") + ErrNoSysAccount = errors.New("system account not setup") ) // configErr is a configuration error. diff --git a/server/events.go b/server/events.go index 60ad0f4c..b54d1dab 100644 --- a/server/events.go +++ b/server/events.go @@ -863,7 +863,7 @@ func (s *Server) sysSubscribe(subject string, cb msgHandler) (*subscription, err return nil, ErrNoSysAccount } if cb == nil { - return nil, fmt.Errorf("Undefined message handler") + return nil, fmt.Errorf("undefined message handler") } s.mu.Lock() sid := strconv.FormatInt(int64(s.sys.sid), 10) diff --git a/server/jwt_test.go b/server/jwt_test.go index 1c1e4275..26917c55 100644 --- a/server/jwt_test.go +++ b/server/jwt_test.go @@ -1006,7 +1006,7 @@ func TestJWTAccountLimitsSubs(t *testing.T) { if !strings.HasPrefix(l, "-ERR") { t.Fatalf("Expected an ERR, got: %v", l) } - if !strings.Contains(l, "Maximum Subscriptions Exceeded") { + if !strings.Contains(l, "maximum subscriptions exceeded") { t.Fatalf("Expected an ERR for max subscriptions exceeded, got: %v", l) } @@ -1022,7 +1022,7 @@ func TestJWTAccountLimitsSubs(t *testing.T) { if !strings.HasPrefix(l, "-ERR") { t.Fatalf("Expected an ERR, got: %v", l) } - if !strings.Contains(l, "Maximum Subscriptions Exceeded") { + if !strings.Contains(l, "maximum subscriptions exceeded") { t.Fatalf("Expected an ERR for max subscriptions exceeded, got: %v", l) } } @@ -1078,7 +1078,7 @@ func TestJWTAccountLimitsSubsButServerOverrides(t *testing.T) { if !strings.HasPrefix(l, "-ERR ") { t.Fatalf("Expected an error") } - if !strings.Contains(l, "Maximum Subscriptions Exceeded") { + if !strings.Contains(l, "maximum subscriptions exceeded") { t.Fatalf("Expected an ERR for max subscriptions exceeded, got: %v", l) } // Read last PONG so does not hold up test. diff --git a/server/monitor.go b/server/monitor.go index 3c62ad22..227a2d5f 100644 --- a/server/monitor.go +++ b/server/monitor.go @@ -136,7 +136,7 @@ func (s *Server) Connz(opts *ConnzOptions) (*Connz, error) { } else { sortOpt = opts.Sort if !sortOpt.IsValid() { - return nil, fmt.Errorf("Invalid sorting option: %s", sortOpt) + return nil, fmt.Errorf("invalid sorting option: %s", sortOpt) } } auth = opts.Username @@ -154,11 +154,11 @@ func (s *Server) Connz(opts *ConnzOptions) (*Connz, error) { // ByStop only makes sense on closed connections if sortOpt == ByStop && state != ConnClosed { - return nil, fmt.Errorf("Sort by stop only valid on closed connections") + return nil, fmt.Errorf("sort by stop only valid on closed connections") } // ByReason is the same. if sortOpt == ByReason && state != ConnClosed { - return nil, fmt.Errorf("Sort by reason only valid on closed connections") + return nil, fmt.Errorf("sort by reason only valid on closed connections") } // If searching by CID @@ -704,7 +704,7 @@ func (s *Server) Subsz(opts *SubszOptions) (*Subsz, error) { testSub = opts.Test test = true if !IsValidLiteralSubject(testSub) { - return nil, fmt.Errorf("Invalid test subject, must be valid publish subject: %s", testSub) + return nil, fmt.Errorf("invalid test subject, must be valid publish subject: %s", testSub) } } } diff --git a/server/opts.go b/server/opts.go index 6007a918..144d101c 100644 --- a/server/opts.go +++ b/server/opts.go @@ -499,11 +499,11 @@ func (o *Options) ProcessConfigFile(configFile string) error { o.LameDuckDuration = dur case "operator", "operators", "roots", "root", "root_operators", "root_operator": opFiles := []string{} - switch v.(type) { + switch v := v.(type) { case string: - opFiles = append(opFiles, v.(string)) + opFiles = append(opFiles, v) case []string: - opFiles = append(opFiles, v.([]string)...) + opFiles = append(opFiles, v...) default: err := &configErr{tk, fmt.Sprintf("error parsing operators: unsupported type %T", v)} errors = append(errors, err) @@ -580,14 +580,14 @@ func (o *Options) ProcessConfigFile(configFile string) error { o.SystemAccount = sa } case "trusted", "trusted_keys": - switch v.(type) { + switch v := v.(type) { case string: - o.TrustedKeys = []string{v.(string)} + o.TrustedKeys = []string{v} case []string: - o.TrustedKeys = v.([]string) + o.TrustedKeys = v case []interface{}: - keys := make([]string, 0, len(v.([]interface{}))) - for _, mv := range v.([]interface{}) { + keys := make([]string, 0, len(v)) + for _, mv := range v { tk, mv = unwrapValue(mv) if key, ok := mv.(string); ok { keys = append(keys, key) @@ -648,11 +648,11 @@ func parseListen(v interface{}) (*hostPort, error) { case string: host, port, err := net.SplitHostPort(vv) if err != nil { - return nil, fmt.Errorf("Could not parse address string %q", vv) + return nil, fmt.Errorf("could not parse address string %q", vv) } hp.port, err = strconv.Atoi(port) if err != nil { - return nil, fmt.Errorf("Could not parse port %q", port) + return nil, fmt.Errorf("could not parse port %q", port) } hp.host = host } @@ -1495,11 +1495,11 @@ func parseAuthorization(v interface{}, opts *Options, errors *[]error, warnings auth.token = mv.(string) case "timeout": at := float64(1) - switch mv.(type) { + switch mv := mv.(type) { case int64: - at = float64(mv.(int64)) + at = float64(mv) case float64: - at = mv.(float64) + at = mv } auth.timeout = at case "users": @@ -1804,7 +1804,7 @@ func parseSubjectPermission(v interface{}, errors, warnings *[]error) (*SubjectP func checkSubjectArray(sa []string) error { for _, s := range sa { if !IsValidSubject(s) { - return fmt.Errorf("Subject %q is not a valid subject", s) + return fmt.Errorf("subject %q is not a valid subject", s) } } return nil @@ -1826,7 +1826,7 @@ func PrintTLSHelpAndDie() { func parseCipher(cipherName string) (uint16, error) { cipher, exists := cipherMap[cipherName] if !exists { - return 0, fmt.Errorf("Unrecognized cipher %s", cipherName) + return 0, fmt.Errorf("unrecognized cipher %s", cipherName) } return cipher, nil @@ -1835,7 +1835,7 @@ func parseCipher(cipherName string) (uint16, error) { func parseCurvePreferences(curveName string) (tls.CurveID, error) { curve, exists := curvePreferenceMap[curveName] if !exists { - return 0, fmt.Errorf("Unrecognized curve preference %s", curveName) + return 0, fmt.Errorf("unrecognized curve preference %s", curveName) } return curve, nil } @@ -1912,11 +1912,11 @@ func parseTLS(v interface{}) (*TLSConfigOpts, error) { } case "timeout": at := float64(0) - switch mv.(type) { + switch mv := mv.(type) { case int64: - at = float64(mv.(int64)) + at = float64(mv) case float64: - at = mv.(float64) + at = mv } tc.Timeout = at default: @@ -1974,7 +1974,7 @@ func GenTLSConfig(tc *TLSConfigOpts) (*tls.Config, error) { pool := x509.NewCertPool() ok := pool.AppendCertsFromPEM(rootPEM) if !ok { - return nil, fmt.Errorf("Failed to parse root ca certificate") + return nil, fmt.Errorf("failed to parse root ca certificate") } config.ClientCAs = pool } @@ -2378,7 +2378,7 @@ func ConfigureOptions(fs *flag.FlagSet, args []string, printVersion, printHelp, // flags). fs.Parse(args) } else if opts.CheckConfig { - return nil, fmt.Errorf("Must specify [-c, --config] option to check configuration file syntax") + return nil, fmt.Errorf("must specify [-c, --config] option to check configuration file syntax") } // Special handling of some flags @@ -2518,7 +2518,7 @@ func processSignal(signal string) error { if l := len(commandAndPid); l == 2 { pid = maybeReadPidFile(commandAndPid[1]) } else if l > 2 { - return fmt.Errorf("Invalid signal parameters: %v", commandAndPid[2:]) + return fmt.Errorf("invalid signal parameters: %v", commandAndPid[2:]) } if err := ProcessSignal(Command(commandAndPid[0]), pid); err != nil { return err diff --git a/server/reload.go b/server/reload.go index 96add700..8ffb91c5 100644 --- a/server/reload.go +++ b/server/reload.go @@ -497,7 +497,7 @@ func (s *Server) Reload() error { s.mu.Lock() if s.configFile == "" { s.mu.Unlock() - return errors.New("Can only reload config when a file is provided using -c or --config") + return errors.New("can only reload config when a file is provided using -c or --config") } newOpts, err := ProcessConfigFile(s.configFile) if err != nil { @@ -665,7 +665,7 @@ func (s *Server) diffOptions(newOpts *Options) ([]option, error) { // If there is really a change prevents reload. if !reflect.DeepEqual(tmpOld, tmpNew) { // See TODO(ik) note below about printing old/new values. - return nil, fmt.Errorf("Config reload not supported for %s: old=%v, new=%v", + return nil, fmt.Errorf("config reload not supported for %s: old=%v, new=%v", field.Name, oldValue, newValue) } case "nolog", "nosigs": @@ -686,7 +686,7 @@ func (s *Server) diffOptions(newOpts *Options) ([]option, error) { // the URL array. // Bail out if attempting to reload any unsupported options. - return nil, fmt.Errorf("Config reload not supported for %s: old=%v, new=%v", + return nil, fmt.Errorf("config reload not supported for %s: old=%v, new=%v", field.Name, oldValue, newValue) } } @@ -973,11 +973,11 @@ func (s *Server) reloadClusterPermissions() { // port, which do not support reload. func validateClusterOpts(old, new ClusterOpts) error { if old.Host != new.Host { - return fmt.Errorf("Config reload not supported for cluster host: old=%s, new=%s", + return fmt.Errorf("config reload not supported for cluster host: old=%s, new=%s", old.Host, new.Host) } if old.Port != new.Port { - return fmt.Errorf("Config reload not supported for cluster port: old=%d, new=%d", + return fmt.Errorf("config reload not supported for cluster port: old=%d, new=%d", old.Port, new.Port) } // Validate Cluster.Advertise syntax diff --git a/server/route.go b/server/route.go index 1601a5f7..27434d9a 100644 --- a/server/route.go +++ b/server/route.go @@ -709,7 +709,7 @@ func (c *client) parseUnsubProto(arg []byte) (string, []byte, []byte, error) { case 3: queue = args[2] default: - return "", nil, nil, fmt.Errorf("Parse Error: '%s'", arg) + return "", nil, nil, fmt.Errorf("parse error: '%s'", arg) } subject = args[1] accountName = string(args[0]) @@ -1041,7 +1041,7 @@ func (s *Server) createRoute(conn net.Conn, rURL *url.URL) *client { didSolicit := rURL != nil r := &route{didSolicit: didSolicit} for _, route := range opts.Routes { - if rURL != nil && (strings.ToLower(rURL.Host) == strings.ToLower(route.Host)) { + if rURL != nil && (strings.EqualFold(rURL.Host, route.Host)) { r.routeType = Explicit } } @@ -1583,9 +1583,7 @@ func (c *client) processRouteConnect(srv *Server, arg []byte, lang string) error // Way to detect clients that incorrectly connect to the route listen // port. Client provide Lang in the CONNECT protocol while ROUTEs don't. if lang != "" { - errTxt := ErrClientConnectedToRoutePort.Error() - c.Errorf(errTxt) - c.sendErr(errTxt) + c.sendErrAndErr(ErrClientConnectedToRoutePort.Error()) c.closeConnection(WrongPort) return ErrClientConnectedToRoutePort } diff --git a/server/server.go b/server/server.go index 3c00fd49..d27e36e7 100644 --- a/server/server.go +++ b/server/server.go @@ -377,11 +377,11 @@ func (s *Server) configureAccounts() error { s.accResolver = opts.AccountResolver if len(opts.resolverPreloads) > 0 { if _, ok := s.accResolver.(*MemAccResolver); !ok { - return fmt.Errorf("Resolver preloads only available for MemAccResolver") + return fmt.Errorf("resolver preloads only available for MemAccResolver") } for k, v := range opts.resolverPreloads { if _, _, err := s.verifyAccountClaims(v); err != nil { - return fmt.Errorf("Preloaded Account: %v", err) + return fmt.Errorf("preloaded Account: %v", err) } s.accResolver.Store(k, v) } @@ -390,7 +390,7 @@ func (s *Server) configureAccounts() error { // Set the system account if it was configured. if opts.SystemAccount != _EMPTY_ { if _, err := s.lookupAccount(opts.SystemAccount); err != nil { - return fmt.Errorf("Error resolving system account: %v", err) + return fmt.Errorf("error resolving system account: %v", err) } } return nil diff --git a/server/util.go b/server/util.go index da95fbd0..0035154e 100644 --- a/server/util.go +++ b/server/util.go @@ -102,7 +102,7 @@ func parseHostPort(hostPort string, defaultPort int) (host string, port int, err } return strings.TrimSpace(host), port, nil } - return "", -1, errors.New("No hostport specified") + return "", -1, errors.New("no hostport specified") } // Returns true if URL u1 represents the same URL than u2,