TempFile creates a temporary file with the specified prefix and suffix
(dir string, prefix string, suffix string)
| 196 | |
| 197 | // TempFile creates a temporary file with the specified prefix and suffix |
| 198 | func TempFile(dir string, prefix string, suffix string) (*os.File, error) { |
| 199 | if dir == "" { |
| 200 | dir = os.TempDir() |
| 201 | } |
| 202 | |
| 203 | name := filepath.Join(dir, fmt.Sprint(prefix, time.Now().UnixNano(), suffix)) |
| 204 | return os.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600) |
| 205 | } |
| 206 | |
| 207 | // ExitFatal ... |
| 208 | func ExitFatal(a ...interface{}) { |