adding in file path option

This commit is contained in:
2025-09-07 01:29:18 -04:00
parent 006af98328
commit a2cb04fd09
2 changed files with 29 additions and 3 deletions
+21 -2
View File
@@ -1,9 +1,28 @@
package lite
type Option func(d *database)
import (
"fmt"
)
var (
ErrBadFilename error = fmt.Errorf("database filename cannot be empty")
)
type Option func(d *database) error
func WithFile(name string) Option {
return func(d *database) {
return func(d *database) error {
if name == "" {
return ErrBadFilename
}
d.file = name
return nil
}
}
func WithPath(path string) Option {
return func(d *database) error {
d.path = path
return nil
}
}