Skip to main content
Log in

Mojo function

getenv

getenv(name: String, default: String = "") -> String

Returns the value of the given environment variable.

Constraints:

The function only works on macOS or Linux and returns an empty string otherwise.

Args:

  • name (String): The name of the environment variable.
  • default (String): The default value to return if the environment variable doesn't exist.

Returns:

The value of the environment variable.

Was this page helpful?