envOf

inline fun <T : Any> envOf(name: String): T

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

This function will throw an exception if the environmental variable can't be found, or the value can't be deserialized.

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.