github.com/wfusion/gofusion@v1.1.14/common/infra/rotatelog/chown_darwin.go (about) 1 //go:build darwin 2 // +build darwin 3 4 package rotatelog 5 6 import ( 7 "os" 8 "syscall" 9 ) 10 11 // osChown is a var so we can mock it out during tests. 12 var osChown = os.Chown 13 14 func chown(name string, info os.FileInfo) error { 15 f, err := os.OpenFile(name, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, info.Mode()) 16 if err != nil { 17 return err 18 } 19 f.Close() 20 stat := info.Sys().(*syscall.Stat_t) 21 return osChown(name, int(stat.Uid), int(stat.Gid)) 22 }