Skip to content

Commit

Permalink
os/user: use stdlib version of this package
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aykevl authored and deadprogram committed Aug 15, 2024
1 parent d3e67cf commit bf8d646
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 60 deletions.
2 changes: 2 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ TEST_PACKAGES_LINUX := \
io/ioutil \
mime/quotedprintable \
net \
os/user \
strconv \
testing/fstest \
text/tabwriter \
Expand All @@ -388,6 +389,7 @@ TEST_PACKAGES_DARWIN := $(TEST_PACKAGES_LINUX)
TEST_PACKAGES_WINDOWS := \
compress/flate \
crypto/hmac \
os/user \
strconv \
text/template/parse \
$(nil)
Expand Down
1 change: 1 addition & 0 deletions compileopts/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func (c *Config) BuildTags() []string {
tags = append(tags, []string{
"tinygo", // that's the compiler
"purego", // to get various crypto packages to work
"osusergo", // to get os/user to work
"math_big_pure_go", // to get math/big to work
"gc." + c.GC(), "scheduler." + c.Scheduler(), // used inside the runtime package
"serial." + c.Serial()}...) // used inside the machine package
Expand Down
1 change: 0 additions & 1 deletion loader/goroot.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ func pathsToOverride(goMinor int, needsSyscallPackage bool) map[string]bool {
"net/": true,
"net/http/": false,
"os/": true,
"os/user/": false,
"reflect/": false,
"runtime/": false,
"sync/": true,
Expand Down
59 changes: 0 additions & 59 deletions src/os/user/user.go

This file was deleted.

0 comments on commit bf8d646

Please sign in to comment.