2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-11 07:41:03 +00:00
restic/snapshot_darwin.go
Alexander Neumann bb777d9a58 Introduce UserID, GroupID for snapshot
Use the fields UID and GID for Unix user and group ID, and the fields
UserID and GroupID for Windows user and group strings.
2015-02-03 22:04:09 +01:00

29 lines
403 B
Go

package restic
import (
"os/user"
"strconv"
)
func (sn *Snapshot) fillUserInfo() error {
usr, err := user.Current()
if err != nil {
return err
}
sn.Username = usr.Username
uid, err := strconv.ParseInt(usr.Uid, 10, 32)
if err != nil {
return err
}
sn.UID = uint32(uid)
gid, err := strconv.ParseInt(usr.Gid, 10, 32)
if err != nil {
return err
}
sn.GID = uint32(gid)
return nil
}