envfile

package
v1.12.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package envfile provides helpers for reading and updating .env files while preserving comments, blank lines, and line order.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyPhpConstUpdates added in v1.0.0

func ApplyPhpConstUpdates(path string, updates map[string]string) error

ApplyPhpConstUpdates rewrites define() values in a PHP file for the given keys. Existing define() calls are updated in-place. Keys that don't exist in the file are appended before "/* That's all" comment, or at the end of the file if not found.

func ApplyUpdates

func ApplyUpdates(path string, updates map[string]string) error

ApplyUpdates rewrites the .env at path, replacing values for any key in updates. Keys not already present are appended at the end. Comments and blank lines are preserved.

func ReadKey added in v0.6.0

func ReadKey(path, key string) string

ReadKey returns the value of a single key from the .env file at path, or an empty string if the key is absent or the file cannot be read.

func ReadKeys added in v1.5.0

func ReadKeys(path string) ([]string, error)

ReadKeys returns all non-comment key names from the .env file at path, in the order they appear.

func ReadPhpConst added in v1.0.0

func ReadPhpConst(path string) (map[string]string, error)

ReadPhpConst reads a WordPress-style wp-config.php file and returns a map of the defined PHP constants (define('KEY', 'value') calls). Only string and numeric constants are captured; boolean/null defines are ignored.

func SyncPrimaryDomain added in v1.10.0

func SyncPrimaryDomain(projectPath, domain string, secured bool) error

SyncPrimaryDomain updates APP_URL and VITE_REVERB_HOST/SCHEME/PORT in the project's .env to reflect the current primary domain and TLS state. Only keys that already exist in the .env are touched. Silently does nothing if no .env exists.

func UpdateAppURL

func UpdateAppURL(projectPath, scheme, domain string) error

UpdateAppURL sets APP_URL in the project's .env to scheme://domain. Silently does nothing if no .env exists.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL