toolbox
toolbox copied to clipboard
Support overriding the HOME environment variable
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.