refactor(internal): replace unmaintained go-hex with stdlib encoding/hex - #1409
Open
donn-duinn wants to merge 1 commit into
Open
refactor(internal): replace unmaintained go-hex with stdlib encoding/hex#1409donn-duinn wants to merge 1 commit into
donn-duinn wants to merge 1 commit into
Conversation
github.com/tmthrgd/go-hex has been unmaintained since 2019, which causes supply-chain / SBOM scanners to flag bun as depending on an abandoned package. internal/hex.go used only EncodedLen and Encode, both of which have identical signatures and semantics in the standard library's encoding/hex, so the emitted SQL is byte-for-byte unchanged. Swap the two calls over to encoding/hex and drop the dependency from every module's go.mod / go.sum via go mod tidy. The transitive golang.org/x/sys that go-hex pulled in is removed from leaf modules where nothing else needed it. Closes uptrace#1385 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Closes #1385.
Motivation
github.com/tmthrgd/go-hexhas been unmaintained since 2019. As noted in #1385, SBOM / supply-chain scanners flagbunas depending on an abandoned package.bunuses only two functions from it, both of which are drop-in equivalents of the standard library.Change
internal/hex.goused onlyEncodedLenandEncode. Both have identical signatures and semantics inencoding/hex, so the emitted SQL (x…byte literals) is byte-for-byte unchanged. Swapped the alias import forencoding/hexand updated the two call sites.go mod tidyin every module so the now-unused dependency is dropped from allgo.mod/go.sumfiles (it was a direct dep in the root module and// indirectacross the dialect/driver/extra/example modules). Wherego-hexwas the sole importer of its transitivegolang.org/x/sys, tidy removes that too.Net result: an abandoned dependency (and one orphaned transitive) is removed with zero additions — every changed line in a
go.mod/go.sumis a deletion.Trade-off
go-hexprovided SIMD-accelerated encoding, soencoding/hexmay be marginally slower when serialising very large[]byte/byteablobs. For typical workloads this is negligible, and the standard library is maintained and patched through normal Go releases. Happy to add a benchmark if you would like to quantify it.Verification
go build ./...andgo vet ./...pass in the root module, alldialect/*,driver/pgdriver,dbfixture, allextra/*, and sampledexample/*modules.go test ./internal/... ./schema/...pass (this is the path that exercisesHexEncoderviaschema/append_value.go).HexEncoderoutput is byte-identical to the previous implementation across empty, single-byte, and multi-byte inputs (including0x00/0xff).0remaining references togo-hex/fasthexanywhere in the tree, and that nogo/toolchaindirectives or unrelated dependency versions changed.