package
0.0.0-20170114144732-49e46f211e5d
Repository: https://github.com/quentinperez/go-stuff.git
Documentation: pkg.go.dev

# README

How to simulate an exception in Golang

  • Using defer + channel
defer func(exc chan<- interface{}) {
	if err := recover(); err != nil {
		exc <- err
	}
}(exception)

Example

Exception caught 0 throw
No exception \o/
No exception \o/
Exception caught 1 throw
No exception \o/
Exception caught 2 throw
Exception caught 3 throw
Exception caught 4 throw
Too many panics