]> Cypherpunks repositories - gostls13.git/commitdiff
os/user: update stub documentation
authorAnthony Martin <ality@pbrane.org>
Tue, 27 Nov 2012 00:02:08 +0000 (16:02 -0800)
committerAnthony Martin <ality@pbrane.org>
Tue, 27 Nov 2012 00:02:08 +0000 (16:02 -0800)
R=golang-dev, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/6844088

src/pkg/os/user/lookup.go [new file with mode: 0644]
src/pkg/os/user/lookup_stubs.go
src/pkg/os/user/lookup_unix.go
src/pkg/os/user/lookup_windows.go

diff --git a/src/pkg/os/user/lookup.go b/src/pkg/os/user/lookup.go
new file mode 100644 (file)
index 0000000..09f00c7
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package user
+
+// Current returns the current user.
+func Current() (*User, error) {
+       return current()
+}
+
+// Lookup looks up a user by username. If the user cannot be found, the
+// returned error is of type UnknownUserError.
+func Lookup(username string) (*User, error) {
+       return lookup(username)
+}
+
+// LookupId looks up a user by userid. If the user cannot be found, the
+// returned error is of type UnknownUserIdError.
+func LookupId(uid string) (*User, error) {
+       return lookupId(uid)
+}
index 415f869f2291b358a1592d20320093dc1e701862..ad06907b5d57760a5deab8a0944bdc911145be8b 100644 (file)
@@ -15,14 +15,14 @@ func init() {
        implemented = false
 }
 
-func Current() (*User, error) {
+func current() (*User, error) {
        return nil, fmt.Errorf("user: Current not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
 }
 
-func Lookup(username string) (*User, error) {
+func lookup(username string) (*User, error) {
        return nil, fmt.Errorf("user: Lookup not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
 }
 
-func LookupId(string) (*User, error) {
+func lookupId(uid string) (*User, error) {
        return nil, fmt.Errorf("user: LookupId not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
 }
index 1102e5bb1bc259b891f451f4a83ccee744b12500..05c34b66e686e8728559b7ead387aa61941f523e 100644 (file)
@@ -29,28 +29,23 @@ static int mygetpwuid_r(int uid, struct passwd *pwd,
 */
 import "C"
 
-// Current returns the current user.
-func Current() (*User, error) {
-       return lookup(syscall.Getuid(), "", false)
+func current() (*User, error) {
+       return lookupUnix(syscall.Getuid(), "", false)
 }
 
-// Lookup looks up a user by username. If the user cannot be found,
-// the returned error is of type UnknownUserError.
-func Lookup(username string) (*User, error) {
-       return lookup(-1, username, true)
+func lookup(username string) (*User, error) {
+       return lookupUnix(-1, username, true)
 }
 
-// LookupId looks up a user by userid. If the user cannot be found,
-// the returned error is of type UnknownUserIdError.
-func LookupId(uid string) (*User, error) {
+func lookupId(uid string) (*User, error) {
        i, e := strconv.Atoi(uid)
        if e != nil {
                return nil, e
        }
-       return lookup(i, "", false)
+       return lookupUnix(i, "", false)
 }
 
-func lookup(uid int, username string, lookupByName bool) (*User, error) {
+func lookupUnix(uid int, username string, lookupByName bool) (*User, error) {
        var pwd C.struct_passwd
        var result *C.struct_passwd
 
index 3626a4e9f059b7b97d2f3fd151045877ffb4f83a..a0a8a4ec10f3fcf4c1c37b323a83cc45a58eaa43 100644 (file)
@@ -68,8 +68,7 @@ func newUser(usid *syscall.SID, gid, dir string) (*User, error) {
        return u, nil
 }
 
-// Current returns the current user.
-func Current() (*User, error) {
+func current() (*User, error) {
        t, e := syscall.OpenCurrentProcessToken()
        if e != nil {
                return nil, e
@@ -103,8 +102,7 @@ func newUserFromSid(usid *syscall.SID) (*User, error) {
        return newUser(usid, gid, dir)
 }
 
-// Lookup looks up a user by username.
-func Lookup(username string) (*User, error) {
+func lookup(username string) (*User, error) {
        sid, _, t, e := syscall.LookupSID("", username)
        if e != nil {
                return nil, e
@@ -115,8 +113,7 @@ func Lookup(username string) (*User, error) {
        return newUserFromSid(sid)
 }
 
-// LookupId looks up a user by userid.
-func LookupId(uid string) (*User, error) {
+func lookupId(uid string) (*User, error) {
        sid, e := syscall.StringToSid(uid)
        if e != nil {
                return nil, e