1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // +build !cgo,!windows,!plan9 android
18 groupImplemented
= false
21 func current() (*User
, error
) {
25 Username
: os
.Getenv("USER"),
27 HomeDir
: os
.Getenv("HOME"),
29 // On NaCL and Android, return a dummy user instead of failing.
46 u
.Username
= "android"
52 // cgo isn't available, but if we found the minimum information
53 // without it, use it:
54 if u
.Uid
!= "" && u
.Username
!= "" && u
.HomeDir
!= "" {
57 return u
, fmt
.Errorf("user: Current not implemented on %s/%s", runtime
.GOOS
, runtime
.GOARCH
)
60 func listGroups(*User
) ([]string, error
) {
61 if runtime
.GOOS
== "android" {
62 return nil, errors
.New("user: GroupIds not implemented on Android")
64 return nil, errors
.New("user: GroupIds requires cgo")
67 func currentUID() string {
68 if id
:= os
.Getuid(); id
>= 0 {
69 return strconv
.Itoa(id
)
71 // Note: Windows returns -1, but this file isn't used on
72 // Windows anyway, so this empty return path shouldn't be
77 func currentGID() string {
78 if id
:= os
.Getgid(); id
>= 0 {
79 return strconv
.Itoa(id
)