-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Refactor some code #3655
Refactor some code #3655
Conversation
Sorry, forgot to test it. |
src/server.go
Outdated
val, err := strconv.Atoi(parts[1]) | ||
if err != nil { | ||
continue | ||
} | ||
switch parts[0] { | ||
case "limit": | ||
val, err := strconv.Atoi(parts[1]) | ||
if err == nil { | ||
params.limit = val | ||
} | ||
params.limit = val | ||
case "offset": | ||
val, err := strconv.Atoi(parts[1]) | ||
if err == nil { | ||
params.offset = val | ||
} | ||
params.offset = val |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this. We don't want to call Atoi
for other unsupported parameters.
This is what I'm suggesting.
switch parts[0] {
case "limit", "offset":
if val, err := strconv.Atoi(parts[1]); err == nil {
if parts[0] == "limit" {
params.limit = val
} else {
params.offset = val
}
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks much better! I'll update it as you suggested. Thank you for your feedback!
Merged, thanks! |
No description provided.