xgo has the following features compared to gomonkey:
Concurrent Safety
xgo has built-in concurrent safety, patchings are isolated among goroutines, tests do not affect each other. While gomonkey is not concurrently safe
Compatibility
xgo provides support through go1.17 to go1.22, for all OS and Arch, while gomonkey has limited support
Stability
xgo does not need to modify readonly area, so on MacOS developers does not need any extra setup
Simplicity
xgo provides a powerful API named Patch, which is isolated per goroutine, so a patch.Reset() is not required as it will be cleared automatically when current tests exits.
This PR changes unit testing to use xgo.
xgo has the following features compared to gomonkey:
Patch
, which is isolated per goroutine, so apatch.Reset()
is not required as it will be cleared automatically when current tests exits.The xgo project: https://github.com/xhd2015/xgo.
To run the tests, ensure xgo has been installed:
Result: