func (s *SafeTempDirExecer) Exec(prefix string, fn func(string) error) (err error) {
	var rootTempDir string
	if rootTempDir, err = ioutil.TempDir(s.Location, prefix); err != nil {
		return
	}
	defer func() {
		failure := recover()
		// Now delete the temporary directory
		if removeErr := remover(rootTempDir); removeErr != nil {
			// There are 3 possible errors here. The panic, the function error
			// and this remove error. Under normal circumstances it out be ok
			// to return an error, but here we could be leaking passwords
			// through the template script and so this will panic
			if failure != nil {
				failure = fmt.Errorf("Original Panic: %v; Failed to clear directory: %v", failure, removeErr)
			} else {
				failure = fmt.Errorf("Failed to clear directory: %v", removeErr)
			}
		}
		if failure != nil {
			panic(failure)
		}
	}()

	err = fn(rootTempDir)
	return
}
// Create a temporary directory in s.Location using 'prefix'. 'fn' is
// then run with the full directory path as the argument. If any errors occur when deleting
// the directory this will panic.
Create a temporary directory in s.Location using 'prefix'. 'fn' is
then run with the full directory path as the argument. If any errors occur when deleting
the directory this will panic.
// Create a temporary directory in s . Location using ' prefix ' . ' fn ' is // then run with the full directory path as the argument . If any errors occur when deleting // the directory this will panic .
func (s *SafeTempDirExecer) Exec(prefix string, fn func(string) error) (err error) {
	var rootTempDir string
	if rootTempDir, err = ioutil.TempDir(s.Location, prefix); err != nil {
		return
	}
	defer func() {
		failure := recover()
		if removeErr := remover(rootTempDir); removeErr != nil {
			if failure != nil {
				failure = fmt.Errorf("Original Panic: %v; Failed to clear directory: %v", failure, removeErr)
			} else {
				failure = fmt.Errorf("Failed to clear directory: %v", removeErr)
			}
		}
		if failure != nil {
			panic(failure)
		}
	}()
	err = fn(rootTempDir)
	return
}
func ( s * SafeTempDirExecer ) Exec ( prefix string , fn func ( string ) error ) ( err error ) { var rootTempDir string if rootTempDir , err = ioutil . TempDir ( s . Location , prefix ) ; err != nil { return } defer func ( ) { failure := recover ( ) if removeErr := remover ( rootTempDir ) ; removeErr != nil { if failure != nil { failure = fmt . Errorf ( " " , failure , removeErr ) } else { failure = fmt . Errorf ( " " , removeErr ) } } if failure != nil { panic ( failure ) } } ( ) err = fn ( rootTempDir ) return }
Create a temporary directory in s.Location using 'prefix'.
Create a temporary directory in s . Location using ' prefix ' .
// Now delete the temporary directory // There are 3 possible errors here. The panic, the function error // and this remove error. Under normal circumstances it out be ok // to return an error, but here we could be leaking passwords // through the template script and so this will panic