2025-06-25 10:35:16 -04:00
|
|
|
package lite
|
|
|
|
|
2025-09-08 17:04:22 -04:00
|
|
|
import "errors"
|
2025-09-07 01:29:18 -04:00
|
|
|
|
|
|
|
var (
|
2025-09-08 17:04:22 -04:00
|
|
|
ErrBadFilename error = errors.New("database filename cannot be empty")
|
2025-09-07 01:29:18 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
type Option func(d *database) error
|
2025-06-25 10:35:16 -04:00
|
|
|
|
|
|
|
func WithFile(name string) Option {
|
2025-09-07 01:29:18 -04:00
|
|
|
return func(d *database) error {
|
|
|
|
if name == "" {
|
|
|
|
return ErrBadFilename
|
|
|
|
}
|
2025-06-25 10:35:16 -04:00
|
|
|
d.file = name
|
2025-09-07 01:29:18 -04:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func WithPath(path string) Option {
|
|
|
|
return func(d *database) error {
|
|
|
|
d.path = path
|
|
|
|
return nil
|
2025-06-25 10:35:16 -04:00
|
|
|
}
|
|
|
|
}
|