mirror of
https://github.com/ManyakRus/crud_generator.git
synced 2024-12-22 00:36:41 +02:00
24 lines
406 B
Go
24 lines
406 B
Go
|
//go:build !windows && !plan9
|
||
|
// +build !windows,!plan9
|
||
|
|
||
|
package copy
|
||
|
|
||
|
import (
|
||
|
"os"
|
||
|
"syscall"
|
||
|
)
|
||
|
|
||
|
func preserveOwner(src, dest string, info fileInfo) (err error) {
|
||
|
if info == nil {
|
||
|
if info, err = os.Stat(src); err != nil {
|
||
|
return err
|
||
|
}
|
||
|
}
|
||
|
if stat, ok := info.Sys().(*syscall.Stat_t); ok {
|
||
|
if err := os.Chown(dest, int(stat.Uid), int(stat.Gid)); err != nil {
|
||
|
return err
|
||
|
}
|
||
|
}
|
||
|
return nil
|
||
|
}
|