Skip to content

Commit 03ad3ed

Browse files
committed
os/user: use stdlib version of this package
I tried implementing enough CGo support to get the native os/user package to work. But I hit a few bugs, probably in CGo itself. Then I realized I could just as well set the osusergo build tag to disable CGo for this specific case. This actually gets the os/user package to work correctly on Linux (I confirmed it returns my name/uid/homedir etc). On other systems, it probably just returns an error if it can't determine these kinds of things. But that's no worse than the current behavior which just doesn't do anything at all.
1 parent 9cb2634 commit 03ad3ed

File tree

4 files changed

+2
-60
lines changed

4 files changed

+2
-60
lines changed

GNUmakefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ TEST_PACKAGES_FAST = \
331331
net/http/internal/ascii \
332332
net/mail \
333333
os \
334+
os/user \
334335
path \
335336
reflect \
336337
sync \

compileopts/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ func (c *Config) BuildTags() []string {
7878
tags = append(tags, []string{
7979
"tinygo", // that's the compiler
8080
"purego", // to get various crypto packages to work
81+
"osusergo", // to get os/user to work
8182
"math_big_pure_go", // to get math/big to work
8283
"gc." + c.GC(), "scheduler." + c.Scheduler(), // used inside the runtime package
8384
"serial." + c.Serial()}...) // used inside the machine package

loader/goroot.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ func pathsToOverride(goMinor int, needsSyscallPackage bool) map[string]bool {
246246
"net/": true,
247247
"net/http/": false,
248248
"os/": true,
249-
"os/user/": false,
250249
"reflect/": false,
251250
"runtime/": false,
252251
"sync/": true,

src/os/user/user.go

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)