21 lines
435 B
Go
21 lines
435 B
Go
package smartconfig
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
// FileResolver reads file contents.
|
|
// Usage: ${FILE:/path/to/file}
|
|
type FileResolver struct{}
|
|
|
|
// Resolve reads the file and returns its contents.
|
|
func (r *FileResolver) Resolve(value string) (string, error) {
|
|
data, err := os.ReadFile(value)
|
|
if err != nil {
|
|
return "", fmt.Errorf("failed to read file %s: %w", value, err)
|
|
}
|
|
return strings.TrimSpace(string(data)), nil
|
|
}
|