How to test Go functions that make syscalls?
I’m not going to waste your time You can find a similar explanation at this github repo from schollii. The idea is simple, yet it might be tedious. You need to define an interface, and use that interface instead of calling os.Getenv, exec.LookPath and any other syscall making function you’re using. Then, you implement this interface with actually calling these function. For testing, you implement the interface with some mock you create or generate....