Add Support for string and []byte Inputs in QRCode Constructors#138
Merged
Conversation
Owner
|
I've upgraded all go.mod to go1.19, please rebase code to retry workflow |
Contributor
Author
|
Ah, thanks for catching that oversight of mine. I completely forgot to check if the codebase is actually targeting a go version that supports the generics syntax, which I should have done before even thinking about making my changes. I've rebased my changes on the latest commit on the upstream main repository and also have taken the liberty to refactor the |
yeqown
approved these changes
Nov 24, 2025
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.
Hey @yeqown,
I would like to propose this PR that updates the QRCode constructors to accept both
stringand[]byteinputs.While the library itself already supports handling data in byte-mode encoding (EncModeByte), the existing constructors required callers to pass a string, leading to unnecessary conversions when working with raw byte data.
The new constructors use a simple generic constraint
(~string | ~[]byte)in order to stay backwards-compatible with downstream consumers of this library and a helper function to normalize inputs to[]bytedata. Internally,buildnow operates solely on raw bytes. ThesourceTextfield appeared to be unused except for tests and thus has been removed in favor of thesourceRawBytesfield that is consumed everywhere in the code internally in order to avoid duplication.Test code has been updated accordingly, and a minor formatting change was made to the debugging logging I couldn't avoid because my code editor just kept reformatting that file, sorry for that.
Hope you like it!