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

consider removing usage of go:linkname #34

Open
majewsky opened this issue Jan 6, 2025 · 0 comments
Open

consider removing usage of go:linkname #34

majewsky opened this issue Jan 6, 2025 · 0 comments

Comments

@majewsky
Copy link

majewsky commented Jan 6, 2025

This package currently uses go:linkname to access database/sql.convertAssign and has earned itself an entry into the "hall of shame" from upstream for that: https://cs.opensource.google/go/go/+/refs/tags/go1.23.4:src/database/sql/convert.go;l=215

However, since Go 1.22.0, there exists a public API that could be used to fix this broken isolation boundary. The behavior of convertAssign is available in sql.Null.Scan() pretty much one-to-one: https://pkg.go.dev/database/sql#Null - The only difference is that it treats nil values differently, but it might be feasible to catch and handle this case explicitly before calling into sql.Null.Scan().

For reference, this is how I replaced another usage of go:linkname convertAssign in a different project: moznion/go-optional#44 - I have not created a PR for this repo since I'm not 100% sure of the semantics involved, but maybe it's similarly straightforward.

Note that using this API requires bumping go.mod to go 1.22, but since any older versions are EOL anyway, that ought to be acceptable.

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

No branches or pull requests

1 participant