On Mon, Jul 31, 2017 at 4:53 PM, Serguei Bezverkhi (sbezverk) <sbezv...@cisco.com> wrote: > > I am having trouble getting GID for a folder. I checked os.Stat api but it > returns only permissions, there is no Uid or Gid. > > stat /mnt/disks/vol2 > File: ‘/mnt/disks/vol2’ > Size: 6 Blocks: 0 IO Block: 4096 directory > Device: fc12h/64530d Inode: 64 Links: 2 > > > Access: (2775/drwxrwsr-x) Uid: ( 0/ root) Gid: ( 2323/ UNKNOWN) < > ------ I need to get this.. > > Greatly appreciate some pointers.
UID and GID are system dependent. Here is sample code for GNU/Linux. Ian package main import ( "fmt" "os" "syscall" ) func main() { fi, err := os.Stat(os.Args[1]) if err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } sys := fi.Sys().(*syscall.Stat_t) fmt.Println("uid:", sys.Uid) fmt.Println("gid:", sys.Gid) } -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.