package filesystem import ( "fmt" "os" syscall "golang.org/x/sys/unix" ) const ( GroupReadWritePerm os.FileMode = syscall.S_IRGRP | syscall.S_IWGRP ) // GroupID will attempt to stat and fetch the group owner id // for the given file path func GroupID(path string) (int64, error) { statInfo := syscall.Stat_t{} if err := syscall.Stat(path, &statInfo); err != nil { return -1, fmt.Errorf("failed to stat file: %w", err) } return int64(statInfo.Gid), nil } // UserID will attempt to stat and fetch the user owner id // for the given file path func UserID(path string) (int64, error) { statInfo := syscall.Stat_t{} if err := syscall.Stat(path, &statInfo); err != nil { return -1, fmt.Errorf("failed to stat file: %w", err) } return int64(statInfo.Uid), nil }