Companion

Functions

Link copied to clipboard
fun fromFile(path: String = ".env", optional: Boolean = true): DotEnvSource

Reads a .env file. A missing file gives an empty source unless optional is false, since a local .env usually exists only on developer machines.

Link copied to clipboard
fun fromResource(path: String, optional: Boolean = false): DotEnvSource

Reads a .env file bundled with the app, see readResourceText for where each platform looks. With optional a missing file gives an empty source instead of an error.

Link copied to clipboard
fun fromString(content: String, origin: String? = null): DotEnvSource

Parses .env text that is already in memory. origin, such as the file name, labels the source in ConfigLoader.explain reports.