Original post

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 https://github.com/golang/go/blob/master/src/os/proc.go#L67. What you can do is wrapping the functions with your own and mocking it.