20 lines
342 B
Go
20 lines
342 B
Go
package test
|
|
|
|
import "os"
|
|
|
|
// CreateTempFile creates a temporary file with given content.
|
|
func CreateTempFile(byts []byte) (string, error) {
|
|
tmpf, err := os.CreateTemp(os.TempDir(), "rtsp-")
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
defer tmpf.Close()
|
|
|
|
_, err = tmpf.Write(byts)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return tmpf.Name(), nil
|
|
}
|