envOfOrNull

inline fun <T : Any> envOfOrNull(name: String): T?

Deserializes the value of an environmental variable, loading from a .env file in the current working directory if possible.

Return

The value of the environmental variable, deserialized to type T.

Parameters

T

Type to deserialize to, which must support kotlinx.serialization.

name

Environmental variable to get the value for.

Throws

Thrown if the environmental variable can't be found.

SerializationException

Thrown if deserialization fails.