2021-02-26 15:52:29 -05:00
|
|
|
package logging
|
|
|
|
|
|
|
|
import (
|
2021-02-27 00:51:58 -05:00
|
|
|
"os"
|
2021-02-26 15:52:29 -05:00
|
|
|
)
|
|
|
|
|
2022-01-05 05:15:38 -05:00
|
|
|
// testOpen attempts to open a file for writing to test for suitability as a LogFile path.
|
2021-02-26 15:52:29 -05:00
|
|
|
func testOpen(path string) (success bool, err error) {
|
2022-01-16 06:55:29 -05:00
|
|
|
|
2021-02-26 15:52:29 -05:00
|
|
|
var f *os.File
|
|
|
|
|
|
|
|
// Example #2, https://golang.org/pkg/os/#OpenFile
|
2021-02-26 20:27:35 -05:00
|
|
|
if f, err = os.OpenFile(path, appendFlags, logPerm); err != nil {
|
2021-02-26 15:52:29 -05:00
|
|
|
return
|
|
|
|
}
|
2022-01-16 06:55:29 -05:00
|
|
|
if err = f.Close(); err != nil {
|
|
|
|
return
|
|
|
|
}
|
2021-02-26 15:52:29 -05:00
|
|
|
|
|
|
|
success = true
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|