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

Refactor some code #3655

Merged
merged 3 commits into from
Mar 5, 2024
Merged

Refactor some code #3655

merged 3 commits into from
Mar 5, 2024

Conversation

onee-only
Copy link
Contributor

No description provided.

@onee-only
Copy link
Contributor Author

Sorry, forgot to test it.

src/server.go Outdated
Comment on lines 239 to 247
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
Copy link
Owner

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
		}
	}
}

Copy link
Contributor Author

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!

@junegunn junegunn merged commit 61bc129 into junegunn:master Mar 5, 2024
5 checks passed
@junegunn
Copy link
Owner

junegunn commented Mar 5, 2024

Merged, thanks!

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.

2 participants