Documentation
¶
Index ¶
Constants ¶
const ( // MaxValueLength is the maximum allowed value length (64KB). MaxValueLength = 64 * 1024 // MaxFileSize is the maximum allowed .env file size (1MB). MaxFileSize = 1024 * 1024 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Conflict ¶
type Conflict struct {
Key string
BaseValue string // value in common ancestor
OurValue string // local value
TheirValue string // remote value
}
Conflict represents a variable modified by both local and remote.
type DiffModified ¶
DiffModified represents a changed variable with old and new values.
type DiffResult ¶
type DiffResult struct {
Added []DiffEntry
Removed []DiffEntry
Modified []DiffModified
// Unchanged keys (not included as entries to save memory).
UnchangedCount int
}
DiffResult represents the diff between two .env files.
func Diff ¶
func Diff(local, remote *EnvFile) *DiffResult
Diff computes the difference between a local and remote EnvFile. local is the current state; remote is the incoming state.
func (*DiffResult) HasChanges ¶
func (d *DiffResult) HasChanges() bool
HasChanges returns true if there are any differences.
func (*DiffResult) Summary ¶
func (d *DiffResult) Summary() string
Summary returns a human-readable summary of changes.
type Entry ¶
type Entry struct {
// Key is the variable name (empty for comments/blank lines).
Key string
// Value is the parsed value.
Value string
// RawLine is the original line for round-trip preservation.
RawLine string
// Type classifies this entry.
Type EntryType
// Quote style used (for round-trip).
Quote QuoteStyle
}
Entry represents a single line/entry in a .env file.
type EnvFile ¶
type EnvFile struct {
Entries []Entry
}
EnvFile represents a parsed .env file preserving structure.
func Parse ¶
Parse parses a .env file from a string, preserving comments, ordering, and blank lines.
func (*EnvFile) Interpolate ¶
func (e *EnvFile) Interpolate()
Interpolate replaces ${VAR} and $VAR references in double-quoted values with the values of other variables defined in the same file. Single-quoted values are never interpolated (they are literal). This is optional and must be called explicitly after Parse().
func (*EnvFile) Set ¶
Set sets a key to a value. If the key exists, it updates it; otherwise appends.
func (*EnvFile) VariableCount ¶
VariableCount returns the number of key-value entries.
type MergeResult ¶
type MergeResult struct {
// Merged is the resulting env file after auto-merge.
Merged *EnvFile
// Conflicts are variables that were modified on both sides.
Conflicts []Conflict
// AutoMerged is the count of variables automatically merged.
AutoMerged int
}
MergeResult is the result of a three-way merge.
func ThreeWayMerge ¶
func ThreeWayMerge(base, ours, theirs *EnvFile) *MergeResult
ThreeWayMerge performs a three-way merge between base, ours, and theirs. base = last synced version, ours = local file, theirs = incoming from peer.
func (*MergeResult) HasConflicts ¶
func (r *MergeResult) HasConflicts() bool
HasConflicts returns true if there are unresolved conflicts.
type QuoteStyle ¶
type QuoteStyle int
QuoteStyle indicates how the value was quoted.
const ( QuoteNone QuoteStyle = iota QuoteSingle // 'value' QuoteDouble // "value" )
type ValidationResult ¶
ValidationResult holds all validation findings.
func Validate ¶
func Validate(ef *EnvFile) *ValidationResult
Validate checks an EnvFile for common issues.
func ValidateRaw ¶
func ValidateRaw(content []byte) *ValidationResult
ValidateRaw validates raw .env file content before parsing.
func (*ValidationResult) HasWarnings ¶
func (v *ValidationResult) HasWarnings() bool
HasWarnings returns true if there are warnings.
func (*ValidationResult) IsValid ¶
func (v *ValidationResult) IsValid() bool
IsValid returns true if there are no errors.