Files
kopia/internal/tempfile/tempfile_unix_fallback.go
Nathan Baulch 657fda216a chore(ci): upgrade to golangci-lint 2.6.1 (#4973)
- upgrade to golangci-lint 2.6.1
- updates for gosec
- updates for govet
- updates for perfsprint
- updates modernize

Leaves out modernize:omitempty due to conflicts with tests
2025-11-11 21:27:10 -08:00

26 lines
577 B
Go

//go:build linux || freebsd || darwin || openbsd
package tempfile
import (
"os"
"github.com/pkg/errors"
)
// createUnixFallback creates a temporary file that does not need to be removed on close.
func createUnixFallback() (*os.File, error) {
f, err := os.CreateTemp("", "kt-")
if err != nil {
return nil, err //nolint:wrapcheck
}
// immediately remove/unlink the file while we keep the handle open.
if derr := os.Remove(f.Name()); derr != nil {
f.Close() //nolint:errcheck
return nil, errors.Wrap(derr, "unable to unlink temporary file")
}
return f, nil
}