Skip to content

fix: remove redundant strings.ToLower in onerrorCommand#703

Open
dlevy-msft-sql wants to merge 2 commits intomicrosoft:mainfrom
dlevy-msft-sql:fix-redundant-tolower
Open

fix: remove redundant strings.ToLower in onerrorCommand#703
dlevy-msft-sql wants to merge 2 commits intomicrosoft:mainfrom
dlevy-msft-sql:fix-redundant-tolower

Conversation

@dlevy-msft-sql
Copy link
Contributor

Problem

The onerrorCommand function has redundant code that makes the codebase harder to read.

Root Cause

strings.EqualFold is already case-insensitive, so wrapping the first argument with strings.ToLower() is unnecessary.

Code Change

Before:

if strings.EqualFold(strings.ToLower(params), "exit") {
    s.Connect.ExitOnError = true
} else if strings.EqualFold(strings.ToLower(params), "ignore") {

After:

if strings.EqualFold(params, "exit") {
    s.Connect.ExitOnError = true
} else if strings.EqualFold(params, "ignore") {

Testing

  • Build passes: go build ./...
  • TestOnErrorCommand passes with live database connection (10.0.0.8)

strings.EqualFold is already case-insensitive, making the
ToLower call unnecessary.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant