Skip to content

godebug stub to fix build error with Go 1.21 #4

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

radfish
Copy link
Contributor

@radfish radfish commented Sep 3, 2023

Upstream interface to internal/godebug has changed, so the sed replace from PR#3 is no longer matching nor is suffcient in Go 1.21. Build fails with errors on lines with godebug references.

c0d381ed1b75be15a45a8d3629c01945e309ece9
Avoid importing internal/godebug

Suggesting a different approach: substitute godebug with a stub. Hopefully it's more robust than hacking more sed replace expression to cover every line. Still might go out of date if upstream changes the interface again, but updating the stub to match the updated interface should be more straightforward than with sed expressions.

Since godebug is accessed via godebug.Foo(), godebug stub needs to be an actual module with its own path. Imports via a relative paths are not allowed in "module mode". True? Or is there a trick to somehow make this godebug stub a "local" module?

The downside of the stub being a module is that now one extra module path needs to be replaced with 'go mod edit' to point to the local directory. And, unfortunately, it is not sufficient to do it only in the dependency module; it needs also needs to be done for the parent application.

Also, for build on Go <1.17 without Go modules, I didn't try it, but presumably no separate command is needed, assuming go get is smart enough to find the nested godebug stub, just like it finds the other local dependencies modules. Not sure.

Upstream interface to internal/godebug has changed, so the sed replace
from PR#3 is no longer matching nor is suffcient in Go 1.21.

	namecoin#3
	c0d381e
	Avoid importing internal/godebug

Suggesting a different approach: substitute godebug with a stub.
Hopefully it's more robust than hacking more sed replace expression
to cover every line.  Still might go out of date if upstream
changes the interface again, but updating the stub to match
the updated interface should be more straightforward than with sed
expressions.

Since godebug is accessed via `godebug.Foo()`, godebug stub needs
to be an actual module with its own path. Imports via a relative paths
are not allowed in "module mode".

The downside of the stub being a module is that now one extra module
path needs to be replaced with 'go mod edit' to point to the local
directory. And, unfortunately, it is not sufficient to do it only in the
dependency module; it needs also needs to be done for the parent
application.

Also, for build on Go <1.17 without Go modules, I didn't try it,
but presumably no separate command is needed, assuming go
get is smart enough to find the nested godebug stub, just like
it finds the other local dependencies modules. Not sure.
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

Successfully merging this pull request may close these issues.

1 participant