From fa4c2fb864c1f9cbcf305631c075e0d69af24cb4 Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Tue, 3 Mar 2015 10:40:04 +1100 Subject: [PATCH] Implemented two missing functions. --- samples/memfs/memfs_test.go | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/samples/memfs/memfs_test.go b/samples/memfs/memfs_test.go index 2cb9e4c..ea2756c 100644 --- a/samples/memfs/memfs_test.go +++ b/samples/memfs/memfs_test.go @@ -7,7 +7,9 @@ import ( "io/ioutil" "log" "os" + "os/user" "path" + "strconv" "strings" "syscall" "testing" @@ -27,9 +29,33 @@ func TestMemFS(t *testing.T) { RunTests(t) } // Helpers //////////////////////////////////////////////////////////////////////// -func currentUid() uint32 +func currentUid() uint32 { + user, err := user.Current() + if err != nil { + panic(err) + } -func currentGid() uint32 + uid, err := strconv.ParseUint(user.Uid, 10, 32) + if err != nil { + panic(err) + } + + return uint32(uid) +} + +func currentGid() uint32 { + user, err := user.Current() + if err != nil { + panic(err) + } + + gid, err := strconv.ParseUint(user.Gid, 10, 32) + if err != nil { + panic(err) + } + + return uint32(gid) +} func timespecToTime(ts syscall.Timespec) time.Time