nodehome

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package nodehome is Node's os.homedir(), which Pi's getHomeDir (package-manager.ts) falls back to when HOME is empty or absent: the home directory the environment names, else the one the system's user database lists for the process's user, else a thrown SystemError. Go's os.UserHomeDir reads the environment alone, and os/user.Current reads the user database alone; neither throws as Node does.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dir

func Dir() (string, error)

Dir is os.homedir(): the home variable of the platform (HOME, or USERPROFILE on Windows) when it is set, an explicit empty value included, else the home directory of the user database's entry for the process's user. With neither it returns *Error.

func Override

func Override(lookup func() (string, error)) (restore func())

Override makes Dir answer with lookup until the returned restore function runs, so a test can stand in a host that has no home directory, which no environment variable can do while the user database lists the test's user. Production code never installs one.

Types

type Error

type Error struct{}

Error is the SystemError Node throws when neither the environment nor the user database names a home directory: ERR_SYSTEM_ERROR, errno ENOENT from libuv's uv_os_homedir. Its text is the message Node's error carries.

func (*Error) Error

func (*Error) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL