Why not create new file when file not exists.
suutaku opened this issue · comments
John_Suu commented
missing create
feature leads developers write external code. why not just add this feature.
Kailash Nadh commented
koanf is not a file-first library. The file
provider is the same as any other provider (bytes, network etc.). It wouldn't be ideal to have file creation functions in the core, and simply creating a non-existent file provides marginal utility.
This should definitely be handled externally. Using the file provider, it should be as simple as something like:
if err := errors.Is(err, os.ErrNotExist) {
// your business logic to create one or more files, populate them with default contents etc.
}