Repository navigation
Report the Code39 checksum value - #99
Merged
Merged
Conversation
Encode("A") reported checksum 0. The mod-43 value of A is 10.
danielwhite
self-requested a review
October 10, 2026 05:11
danielwhite
requested changes
Oct 11, 2026
danielwhite
left a comment
Collaborator
There was a problem hiding this comment.
@SashaMIT, thanks for the spot. If you can simplify this for clarity, I think this is good to ship.
Comment on lines
+146
to
+150
| checkSum := 0 | ||
| if cs := []rune(getChecksum(content)); len(cs) == 1 { | ||
| if info, ok := encodeTable[cs[0]]; ok && info.value >= 0 { | ||
| checkSum = info.value | ||
| } |
Collaborator
There was a problem hiding this comment.
I think with a minor change to have getChecksum return a rune, it would eliminate the conditional checks and avoid computing the checksum twice.
For example:
checkChar := getChecksum(content)
if includeChecksum {
data += string(checkChar)
}
[ ... ]
checkSum := encodeTable[checkChar].value
return utils.New1DCodeIntCheckSumWithColor(..., checkSum, color), nilThe encoder looked the character up twice and parsed it back to a value.
Contributor
Author
|
Thanks for the review. getChecksum now returns the rune, and the encoder reads that value from the table once. |
danielwhite
approved these changes
Oct 13, 2026
danielwhite
left a comment
Collaborator
There was a problem hiding this comment.
Looks good. Thanks!
Contributor
Author
|
Thanks for merging this. Glad the rune return was the right shape. |
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.
Summary
CheckSumparsed the mod-43 character withstrconv.ParseInt. Digits survived. A letter or symbol failed the parse and was stored as 0.Encode("A")reported checksum 0. A is value 10.Encode("1")still reports 1. The bars are unchanged.Test plan
Test_ChecksumValuefails:Encode("A")checksum is 0go test ./code39/passesMade with Cursor