Skip to content

Commit 143fd8e

Browse files
author
Elias Naur
committed
os/user: use the stubs fallback for Android
Using the stubs, user.Current will no longer fail on Android, fixing the os/exec.TestCredentialNoSetGroups test. Change-Id: I8b9842aa6704c0cde383c549a614bab0a0ed7695 Reviewed-on: https://go-review.googlesource.com/37765 Run-TryBot: Elias Naur <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent e99dafc commit 143fd8e

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

src/os/user/lookup_android.go

-13
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,6 @@ package user
88

99
import "errors"
1010

11-
func init() {
12-
userImplemented = false
13-
groupImplemented = false
14-
}
15-
16-
func current() (*User, error) {
17-
return nil, errors.New("user: Current not implemented on android")
18-
}
19-
2011
func lookupUser(string) (*User, error) {
2112
return nil, errors.New("user: Lookup not implemented on android")
2213
}
@@ -32,7 +23,3 @@ func lookupGroup(string) (*Group, error) {
3223
func lookupGroupId(string) (*Group, error) {
3324
return nil, errors.New("user: LookupGroupId not implemented on android")
3425
}
35-
36-
func listGroups(*User) ([]string, error) {
37-
return nil, errors.New("user: GroupIds not implemented on android")
38-
}

src/os/user/lookup_stubs.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// +build !cgo,!windows,!plan9,!android
5+
// +build !cgo,!windows,!plan9 android
66

77
package user
88

@@ -46,6 +46,9 @@ func current() (*User, error) {
4646
}
4747

4848
func listGroups(*User) ([]string, error) {
49+
if runtime.GOOS == "android" {
50+
return nil, errors.New("user: GroupIds not implemented on Android")
51+
}
4952
return nil, errors.New("user: GroupIds requires cgo")
5053
}
5154

0 commit comments

Comments
 (0)