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

Support overriding the HOME environment variable #1564

Open
debarshiray opened this issue Oct 10, 2024 · 0 comments
Open

Support overriding the HOME environment variable #1564

debarshiray opened this issue Oct 10, 2024 · 0 comments

Comments

@debarshiray
Copy link
Member

Currently, if the HOME environment variable is temporarily overriden, toolbox(1) doesn't respect it. This is likely because Go's os/user doesn't respect the variable. Instead, it could be better to use os.UserHomeDir.

package main

import (
	"fmt"
	"os"
	"os/user"
)

func main() {
	user, _ := user.Current()
	fmt.Printf("%s\n", user.HomeDir)

	userHomeDir, err := os.UserHomeDir()
	fmt.Printf("%s, %s\n", userHomeDir, err)
}
$ HOME=/tmp go run user.go
/home/rishi
/tmp, %!s(<nil>)

See the discussion from here for the original motivation.

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

1 participant