Generic swapping in go

from blog blog, | ↗ original
Generic swapping in go When writing tests, overriding global values/defaults1 can become pretty handy for mocking. But as always with global resources, they need to be used carefully2. Otherwise other tests may behave strangely. Therefore a test should make sure those values are reset to its original value regardless of the test result. Here you...