-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
cmd/compile: go:linkname does not work with dot in importpath #67361
Comments
The go:linkname directive is not part of the language and its use in user code is highly discouraged. It can break at any time without warning. From what I see in your example you can just import the package as-is, there is no need to use linkname, plus I'm not sure if it even works with external packages, I have mainly seen its use with internal Go libraries. |
see #63846 (comment) |
//go:linkname DBBeforeQuery github.com/uptrace/bun.(*DB).beforeQuery
func DBBeforeQuery(
instance *bun.DB,
ctx context.Context,
iquery bun.Query,
queryTemplate string,
queryArgs []interface{},
query string,
model bun.Model,
) (context.Context, *bun.QueryEvent) |
Hi! I found the actual symbol name by go tool compile. "." in the last part of package name is encoded: // gopkg.in/yaml.v2 => gopkg.in/yaml%2ev2
//go:linkname newEncoder2 gopkg.in/yaml%2ev2.newEncoder
func newEncoder2() any |
…ut secret (#58) * accessing internal yaml v3 methods, see golang/go#67361 * added tests for client worker's connection opening since the YAML change, all practically optional fields in config can be turned optional by removing the value checks.
Go version
go1.22.1 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
Use go linkname with gopkg.in/yaml.v3 or gopkg.in/yaml.v2
playground: https://go.dev/play/p/1yYtFVvGnfn
What did you see happen?
relocation target gopkg.in/yaml.v2.newEncoder not defined
What did you expect to see?
The symbol is imported and can be called.
The text was updated successfully, but these errors were encountered: