Files
gluetun/internal/publicip/fs.go
Quentin McGaw (desktop) 21f4cf7ab5 Maint: do not mock os functions
- Use filepaths with /tmp for tests instead
- Only mock functions where filepath can't be specified such as user.Lookup
2021-07-23 16:06:19 +00:00

26 lines
414 B
Go

package publicip
import (
"os"
)
func persistPublicIP(path string, content string, puid, pgid int) error {
file, err := os.OpenFile(path, os.O_TRUNC|os.O_WRONLY|os.O_CREATE, 0644)
if err != nil {
return err
}
_, err = file.WriteString(content)
if err != nil {
_ = file.Close()
return err
}
if err := file.Chown(puid, pgid); err != nil {
_ = file.Close()
return err
}
return file.Close()
}