Functions
getEnv | I Returns the environment variable value associated with the provided name. |
getUserHome | I Returns the current user's home directory path. |
getUsername | I Returns the current user's name. |
listEnv | I Returns a map of environment variables. |
setEnv | I Sets the value of the environment variable named by the key. |
unsetEnv | I Removes a single environment variable from the system if it exists. |
getEnv
Returns the environment variable value associated with the provided name.
1string port = os:getEnv("HTTP_PORT");
Parameters
- name string
Name of the environment variable
getUserHome
function getUserHome() returns string
Returns the current user's home directory path.
1string userHome = os:getUserHome();
getUsername
function getUsername() returns string
Returns the current user's name.
1string username = os:getUsername();
listEnv
Returns a map of environment variables.
1map<string> envs = os:listEnv();
setEnv
Sets the value of the environment variable named by the key. Note that the parameter key cannot be an empty string or "==" sign.
1os:Error? err = os:setEnv("BALCONFIGFILE", "/path/to/Config.toml");
unsetEnv
Removes a single environment variable from the system if it exists. Note that the parameter key cannot be an empty string.
1os:Error? err = os:unsetEnv("BALCONFIGFILE");
Parameters
- key string
Key of the environment variable