On this page
std/envvars
Source EditThe std/envvars
module implements environment variable handling.
Imports
Types
Procs
-
proc getEnv(key: string; default = ""): string {....tags: [ReadEnvEffect], raises: [], forbids: [].}
-
Returns the value of the environment variable named
key
.If the variable does not exist,
""
is returned. To distinguish whether a variable exists or it's value is just""
, call existsEnv(key) proc.See also:
Example:
Source Editassert getEnv("unknownEnv") == "" assert getEnv("unknownEnv", "doesn't exist") == "doesn't exist"
Iterators
-
iterator envPairs(): tuple[key, value: string] {....tags: [ReadEnvEffect], raises: [], forbids: [].}
-
Iterate over all environments variables.
In the first component of the tuple is the name of the current variable stored, in the second its value.
Works in native backends, nodejs and vm, like the following APIs:
Source Edit
© 2006–2024 Andreas Rumpf
Licensed under the MIT License.
https://nim-lang.org/docs/envvars.html