Conversation
Signed-off-by: Azanul <azanulhaque@gmail.com>
Please double check the following review of the pull request:
Changes in the diff
Identified Issues
Issue 001ExplanationIn the new code added to fmt.Errorf("expected count to be greater than 0, got %d", count)While this is clear, Go error messages conventionally start with a lowercase letter and avoid punctuation at the end unless necessary. Also, the message could be more idiomatic by stating "count must be greater than zero" rather than "expected count to be greater than 0". Suggested fixif count <= 0 {
return "", fmt.Errorf("count must be greater than zero, got %d", count)
}Explanation of the fixThis change improves readability and aligns the error message with Go error message conventions, making it clearer and more idiomatic. Missing tests for the incoming changesAdd tests for the
Example test code: func TestRandomBytesInHex(t *testing.T) {
// Test invalid counts
for _, count := range []int{0, -1, -10} {
_, err := randomBytesInHex(count)
if err == nil {
t.Errorf("expected error for count %d, got nil", count)
}
}
// Test valid count
count := 16
hexStr, err := randomBytesInHex(count)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
expectedLen := count * 2 // hex encoding doubles length
if len(hexStr) != expectedLen {
t.Errorf("expected length %d, got %d", expectedLen, len(hexStr))
}
}Summon me to re-review when updated! Yours, Gooroo.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes issue #
Proposed Changes