FAQ
The problem came up while trying to walk a filesystem tree and find all
files owned by a given user.

I found a go function that can set the user/group/date/modbits of a file
but nothing that can read the user or group. I expected to see it in the
os pkg as part of type FileInfo. It's late so I may have missed something
obvious but... any hints appreciated.

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Rob Pike at Mar 16, 2013 at 5:19 am
    It's OS-specific. You need to unpack the Sys field of the FileInfo
    using the type appropriate for your system.

    -rob

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Hotei at Mar 16, 2013 at 3:16 pm
    Rob, Thanks for the quick reply. It took a few minutes of browsing the os
    testing source to find the correct "unpacking" magic, but the code below
    seems to work.

    // Simple/fileinfo.go

    // +build darwin freebsd linux netbsd openbsd

    package main

    import (
    "fmt"
    "os"
    "syscall"
    )

    func main() {
    fmt.Printf("startup\n")
    fi, err := os.Stat("fileinfo.go")
    if err != nil {
    fmt.Printf("err %v\n", err)
    os.Exit(1)
    }
    fmt.Printf("fi %v\n\n\n", fi)
    sys := fi.Sys().(*syscall.Stat_t)
    fmt.Printf("UID = %d\n", int(sys.Uid))
    fmt.Printf("GID = %d\n", int(sys.Gid))
    }


    On Saturday, March 16, 2013 12:37:40 AM UTC-4, Hotei wrote:

    The problem came up while trying to walk a filesystem tree and find all
    files owned by a given user.

    I found a go function that can set the user/group/date/modbits of a file
    but nothing that can read the user or group. I expected to see it in the
    os pkg as part of type FileInfo. It's late so I may have missed something
    obvious but... any hints appreciated.
    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMar 16, '13 at 4:37a
activeMar 16, '13 at 3:16p
posts3
users2
websitegolang.org

2 users in discussion

Hotei: 2 posts Rob Pike: 1 post

People

Translate

site design / logo © 2022 Grokbase