createUnixFallback creates a temporary file that does not need to be removed on close.
()
| 10 | |
| 11 | // createUnixFallback creates a temporary file that does not need to be removed on close. |
| 12 | func createUnixFallback() (*os.File, error) { |
| 13 | f, err := os.CreateTemp("", "kt-") |
| 14 | if err != nil { |
| 15 | return nil, err //nolint:wrapcheck |
| 16 | } |
| 17 | |
| 18 | // immediately remove/unlink the file while we keep the handle open. |
| 19 | if derr := os.Remove(f.Name()); derr != nil { |
| 20 | f.Close() //nolint:errcheck |
| 21 | return nil, errors.Wrap(derr, "unable to unlink temporary file") |
| 22 | } |
| 23 | |
| 24 | return f, nil |
| 25 | } |
no test coverage detected