Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is this still relevant? #34

Open
sathishvj opened this issue Sep 19, 2023 · 3 comments
Open

Is this still relevant? #34

sathishvj opened this issue Sep 19, 2023 · 3 comments

Comments

@sathishvj
Copy link

The os package code seems to be almost the very same. So, is this package still relevant? Or is the std lib os still using cgo somewhere?

From package os.

func UserHomeDir() (string, error) {
	env, enverr := "HOME", "$HOME"
	switch runtime.GOOS {
	case "windows":
		env, enverr = "USERPROFILE", "%userprofile%"
	case "plan9":
		env, enverr = "home", "$home"
	}
	if v := Getenv(env); v != "" {
		return v, nil
	}
	// On some geese the home directory is not always defined.
	switch runtime.GOOS {
	case "android":
		return "/sdcard", nil
	case "ios":
		return "/", nil
	}
	return "", errors.New(enverr + " is not defined")
}
@dolmen
Copy link

dolmen commented Mar 21, 2024

os.UserHomeDir() appeared with Go 1.12.

@dolmen
Copy link

dolmen commented Mar 21, 2024

Also the primary motivation for this package (from README.md) what that os/user was using cgo on Darwin. But since Go 1.20 this is no longer the case (see golang/go@185766d) and os/user even exposes a osusergo build tag to force avoiding cgo.

@PeterCardenas
Copy link

i went down this rabbit hole of finding this repo after seeing it in autocomplete 😅. I would appreciate if this repo was archived so that it's more obvious that this shouldn't be used

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants