Skip to content

Commit bf8d646

Browse files
aykevldeadprogram
authored andcommitted
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 d3e67cf commit bf8d646

File tree

4 files changed

+3
-60
lines changed

4 files changed

+3
-60
lines changed

GNUmakefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ TEST_PACKAGES_LINUX := \
378378
io/ioutil \
379379
mime/quotedprintable \
380380
net \
381+
os/user \
381382
strconv \
382383
testing/fstest \
383384
text/tabwriter \
@@ -388,6 +389,7 @@ TEST_PACKAGES_DARWIN := $(TEST_PACKAGES_LINUX)
388389
TEST_PACKAGES_WINDOWS := \
389390
compress/flate \
390391
crypto/hmac \
392+
os/user \
391393
strconv \
392394
text/template/parse \
393395
$(nil)

compileopts/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ func (c *Config) BuildTags() []string {
8484
tags = append(tags, []string{
8585
"tinygo", // that's the compiler
8686
"purego", // to get various crypto packages to work
87+
"osusergo", // to get os/user to work
8788
"math_big_pure_go", // to get math/big to work
8889
"gc." + c.GC(), "scheduler." + c.Scheduler(), // used inside the runtime package
8990
"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
@@ -247,7 +247,6 @@ func pathsToOverride(goMinor int, needsSyscallPackage bool) map[string]bool {
247247
"net/": true,
248248
"net/http/": false,
249249
"os/": true,
250-
"os/user/": false,
251250
"reflect/": false,
252251
"runtime/": false,
253252
"sync/": true,

src/os/user/user.go

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

0 commit comments

Comments
 (0)