diff --git a/fs/file.go b/fs/file.go index c5d80cc..5000acc 100644 --- a/fs/file.go +++ b/fs/file.go @@ -8,3 +8,17 @@ func Exists(path string) bool { _, err := os.Stat(path) return !os.IsNotExist(err) } + +func TmpFile(name string, contents []byte) (string, error) { + f, err := os.CreateTemp("", name) + if err != nil { + return "", err + } + defer f.Close() + + if _, err := f.Write(contents); err != nil { + return "", err + } + + return f.Name(), nil +}