How to test os.exit?

How can we test the log.fatal() or any function that causes the os.exit() ?

for example if i have a function

func f(){

so how can i test it without causing tests to fail.

I’m not sure if it’s possible. It calls a syscall directly What you can do is wrapping the functions with your own and mocking it.