-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Description
The android GOOS is generally a special case of linux, and the ios GOOS is generally a special case of darwin.
However, the behavior of os.UserHomeDir on android and ios deviates from the standard behavior for linux and darwin.
androidwas special-cased to return/in https://go.dev/cl/139717.- The commit message and code-review comments do not explain why, as far as I can tell, and no code comment was added explaining it either.
- Its path was changed to
/sdcardin https://go.dev/cl/169540 for os: The result of UserHomeDir and User.HomeDir is inconsistent. #31070, to match an existing special case inos/user.- That special case was added in https://go.dev/cl/37960, with the explanation “return a dummy user instead of failing”. However, it did not explain why failing is not the correct behavior in that configuration, as I would expect it to be — it seems like the code was changed to conform to an erroneous test, instead of changing the test to conform to the previously-correct(?) code.
ioswas special-cased to return/in https://go.dev/cl/141798.- The explanation given was that “The UserHomeDir test succeeds on the builder, but not when run
manually where HOME is set to the host $HOME.” - To me, that seems like a bug in the
execwrapper, notos.UserHomeDir— and, indeed, later (in https://go.dev/cl/167938) the wrapper was changed to avoid propagating$HOMEto the device.
- The explanation given was that “The UserHomeDir test succeeds on the builder, but not when run
A month after the two special cases were added, the signature of UserHomeDir was changed to include an error return value (#28562). It seems to me that the special cases should have been removed at that point, but they weren't, and I think that was an oversight.
I propose that we add a GODEBUG guard for those special cases (mostly for a smoother version-based transition per #56986) and default UserHomeDir and os/user.Current on android and ios to be consistent with linux and darwin respectively as of the next Go version.
(CC @golang/android @golang/ios)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status