package thumbs import ( "fmt" "os" "os/user" "strconv" "syscall" ) // ownerOf is "root:render 0660" for a device node, the thing to say when it cannot be opened. func ownerOf(st os.FileInfo) string { sys, ok := st.Sys().(*syscall.Stat_t) if !ok { return "" } u := strconv.Itoa(int(sys.Uid)) if x, err := user.LookupId(u); err == nil { u = x.Username } g := strconv.Itoa(int(sys.Gid)) if x, err := user.LookupGroupId(g); err == nil { g = x.Name } return fmt.Sprintf("%s:%s %04o", u, g, st.Mode().Perm()) }