func PanicsRE(f func(), wantRE string) (didPanic bool, pMatchesRE bool, pVal interface{}) {
	// Compile so that we can fail immediately if the RE is invalid
	re, err := regexp.Compile(wantRE)
	if err != nil {
		panic(fmt.Sprintf("Regexp could not be compiled: %s", err))
	}

	defer func() {
		pVal = recover()
		didPanic = pVal != nil
		pStr, ok := pVal.(string)
		if !ok {
			var pErr error // pre-allocated so we can reuse ok
			pErr, ok = pVal.(error)
			if !ok {
				pMatchesRE = false
			} else {
				pStr = pErr.Error()
			}
		}
		if ok { // one of the type assertions succeeded
			pMatchesRE = re.MatchString(pStr)
		}
	}()
	f()
	return false, false, nil // overridden by the deferred function; here for the compiler
}
// PanicsRE tests if the given function panics, and returns a boolean that is true if it does.  It also takes a string,
// to allow checking the contents of the panic; if the function does panic, and the panic can be cast to a string
// matching the regular expression given by wantRE, pMatchesRE will be true.  If the panic can be cast to an error
// value, the error's Error() string will be used for the check.  The panic value itself is also returned.
// (Specifically, this is the return value from recover(), which is nil if the function did not panic.)
//
// See PanicsStr() for a plain-string-flavored version of how to use this function.
//
// The contents check can be bypassed by setting wantRE to "", which matches any string.  In this case,
// pMatchesRE will always be true (assuming the panic can be cast to a string), and you will still get the panic value.
//
// PanicsRE itself panics if wantRE does not represent a valid regular expression.
PanicsRE tests if the given function panics, and returns a boolean that is true if it does.  It also takes a string,
to allow checking the contents of the panic; if the function does panic, and the panic can be cast to a string
matching the regular expression given by wantRE, pMatchesRE will be true.  If the panic can be cast to an error
value, the error's Error() string will be used for the check.  The panic value itself is also returned.
(Specifically, this is the return value from recover(), which is nil if the function did not panic.)

See PanicsStr() for a plain-string-flavored version of how to use this function.

The contents check can be bypassed by setting wantRE to "", which matches any string.  In this case,
pMatchesRE will always be true (assuming the panic can be cast to a string), and you will still get the panic value.

PanicsRE itself panics if wantRE does not represent a valid regular expression.
// PanicsRE tests if the given function panics and returns a boolean that is true if it does . It also takes a string // to allow checking the contents of the panic ; if the function does panic and the panic can be cast to a string // matching the regular expression given by wantRE pMatchesRE will be true . If the panic can be cast to an error // value the error ' s Error () string will be used for the check . The panic value itself is also returned . // ( Specifically this is the return value from recover () which is nil if the function did not panic . ) // // See PanicsStr () for a plain - string - flavored version of how to use this function . // // The contents check can be bypassed by setting wantRE to " " which matches any string . In this case // pMatchesRE will always be true ( assuming the panic can be cast to a string ) and you will still get the panic value . // // PanicsRE itself panics if wantRE does not represent a valid regular expression .
func PanicsRE(f func(), wantRE string) (didPanic bool, pMatchesRE bool, pVal interface{}) {
	re, err := regexp.Compile(wantRE)
	if err != nil {
		panic(fmt.Sprintf("Regexp could not be compiled: %s", err))
	}
	defer func() {
		pVal = recover()
		didPanic = pVal != nil
		pStr, ok := pVal.(string)
		if !ok {
			var pErr error 
			pErr, ok = pVal.(error)
			if !ok {
				pMatchesRE = false
			} else {
				pStr = pErr.Error()
			}
		}
		if ok { 
			pMatchesRE = re.MatchString(pStr)
		}
	}()
	f()
	return false, false, nil 
}
func PanicsRE ( f func ( ) , wantRE string ) ( didPanic bool , pMatchesRE bool , pVal interface { } ) { re , err := regexp . Compile ( wantRE ) if err != nil { panic ( fmt . Sprintf ( " " , err ) ) } defer func ( ) { pVal = recover ( ) didPanic = pVal != nil pStr , ok := pVal . ( string ) if ! ok { var pErr error pErr , ok = pVal . ( error ) if ! ok { pMatchesRE = false } else { pStr = pErr . Error ( ) } } if ok { pMatchesRE = re . MatchString ( pStr ) } } ( ) f ( ) return false , false , nil }
PanicsRE tests if the given function panics, and returns a boolean that is true if it does.
PanicsRE tests if the given function panics and returns a boolean that is true if it does .
// Compile so that we can fail immediately if the RE is invalid // pre-allocated so we can reuse ok // one of the type assertions succeeded // overridden by the deferred function; here for the compiler