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

Fix govet linting errors raised by updated linter #768

Merged
merged 1 commit into from
Aug 19, 2024
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
2 changes: 1 addition & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ func New(appType AppType) (*Config, error) {
// someone needs to debug later what happened (and the person
// running the application didn't catch the error output).
errMsg := "failed to load configuration file"
config.Log.Error().Err(err).Msgf(errMsg)
config.Log.Error().Err(err).Msg(errMsg)

return nil, fmt.Errorf("%s: %w", errMsg, err)
}
Expand Down
18 changes: 4 additions & 14 deletions internal/mbxs/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,9 @@ var (
func Login(c *client.Client, username string, password string, logger zerolog.Logger) error {

if c == nil {
errMsg := fmt.Sprintf(
"invalid (nil) client received while attempting login for account %s",
username,
)

logger.Error().Msg(errMsg)
logger.Error().Str("account", username).Msg("invalid (nil) client received while attempting login")

return fmt.Errorf(errMsg)
return fmt.Errorf("invalid (nil) client received while attempting login for account: %v", username)
}

// Due to logic applied during connection establishment this is highly
Expand Down Expand Up @@ -115,14 +110,9 @@ func OAuth2ClientCredsAuth(
) error {

if imapClient == nil {
errMsg := fmt.Sprintf(
"invalid (nil) client received while attempting login for client ID %s",
clientID,
)

logger.Error().Msg(errMsg)
logger.Error().Str("client_id", clientID).Msg("invalid (nil) client received while attempting login")

return fmt.Errorf(errMsg)
return fmt.Errorf("invalid (nil) client received while attempting login for client ID: %v", clientID)
}

// Due to logic applied during connection establishment this is highly
Expand Down
52 changes: 26 additions & 26 deletions internal/mbxs/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ import (
func openConnection(addrs []string, port int, dialer Dialer, tlsConfig *tls.Config, logger zerolog.Logger) (*client.Client, error) {

if len(addrs) < 1 {
errMsg := "empty list of IP Addresses received"
logger.Error().Msg("empty list of IP Addresses received")

logger.Error().Msg(errMsg)

return nil, fmt.Errorf(errMsg)
return nil, fmt.Errorf("empty list of IP Addresses received")
}

var c *client.Client
Expand Down Expand Up @@ -119,15 +117,9 @@ func Connect(server string, port int, netType string, minTLSVer uint16, logger z

switch {
case len(lookupResults) < 1:
errMsg := fmt.Sprintf(
"failed to resolve hostname %s to IP Addresses",
server,
)
logger.Error().Str("server", server).Msg("failed to resolve hostname to IP Addresses")

logger.Error().
Msg(errMsg)

return nil, fmt.Errorf(errMsg)
return nil, fmt.Errorf("failed to resolve hostname to IP Addresses: %v", server)

default:
logger.Debug().
Expand Down Expand Up @@ -155,15 +147,19 @@ func Connect(server string, port int, netType string, minTLSVer uint16, logger z

switch {
case len(ips) < 1:
errMsg := fmt.Sprintf(
"failed to to convert DNS lookup results to net.IP values after receiving %d DNS lookup results ([%s])",
len(lookupResults),
strings.Join(lookupResults, ", "),
)
numLookupResults := len(lookupResults)
lookupResultsList := strings.Join(lookupResults, ", ")

logger.Error().Msg(errMsg)
logger.Error().
Int("num_lookup_results", numLookupResults).
Str("lookup_results", lookupResultsList).
Msg("failed to to convert DNS lookup results to net.IP values after receiving DNS lookup results")

return nil, fmt.Errorf(errMsg)
return nil, fmt.Errorf(
"failed to to convert DNS lookup results to net.IP values after receiving %d DNS lookup results ([%s])",
numLookupResults,
lookupResultsList,
)

default:
logger.Debug().Msg("successfully converted DNS lookup results to net.IP values")
Expand Down Expand Up @@ -208,15 +204,19 @@ func Connect(server string, port int, netType string, minTLSVer uint16, logger z
// requirement.
switch {
case len(addrs) < 1:
errMsg := fmt.Sprintf(
"failed to gather IP Addresses for connection attempts after receiving and parsing %d DNS lookup results ([%s])",
len(lookupResults),
strings.Join(lookupResults, ", "),
)
numLookupResults := len(lookupResults)
lookupResultsList := strings.Join(lookupResults, ", ")

logger.Error().Msg(errMsg)
logger.Error().
Int("num_lookup_results", numLookupResults).
Str("lookup_results", lookupResultsList).
Msg("failed to gather IP Addresses for connection attempts after receiving and parsing DNS lookup results")

return nil, fmt.Errorf(errMsg)
return nil, fmt.Errorf(
"failed to gather IP Addresses for connection attempts after receiving and parsing %d DNS lookup results ([%s])",
numLookupResults,
lookupResultsList,
)

default:
logger.Debug().
Expand Down
Loading