mirror of
https://github.com/qdm12/gluetun.git
synced 2026-05-07 04:20:12 +02:00
21f4cf7ab5
- Use filepaths with /tmp for tests instead - Only mock functions where filepath can't be specified such as user.Lookup
26 lines
414 B
Go
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()
|
|
}
|