[go1.20] internal/godebug env watcher update#1313
[go1.20] internal/godebug env watcher update#1313nevkontakte merged 1 commit intogopherjs:go1.20from
Conversation
nevkontakte
left a comment
There was a problem hiding this comment.
I'd like to avoid modifying the global environment, since it creates a risk of conflicting with some other library, even if the chance of that happening in stdlib tests is slim.
Since we are already overriding Setenv/Getenv implementations, can we implement the hook at Go level instead?
|
That makes sense. I was trying to make the injection such that any other proxy could also inject on top or below it, but it is worrying that it is modifying It does appear that anytime this callback is being used is being done via testing I'll rework it. |
|
Yeah, I can also imagine runtimes that doesn't allow reassigning |
be1cb06 to
c849f60
Compare
In
internal/godebugthesetUpdatemethod is used to watch for changes to the environment variableGODEBUG. This is used by tests such as thearchive/ziptestTestInsecurePathsor any test usingt.Setenv.To solve this I added a way to inject a JS
Proxyintoprocess.envthat calls a callback when any environment variable is set, the callback will handle the rest of the update and call the function provided tosetUpdate.Testing this was a little hard since
godebugis used by tests. I solved this by creating a go:link from a test that is external togodebug.This is part of #1270