Files
yellowjacket/backend/library/library.go
T
2025-03-24 15:32:38 -05:00

45 lines
704 B
Go

package library
import (
"context"
"fmt"
)
type Config struct {
DirectoryPath string
}
func (c *Config) Validate() error {
return nil
}
var DefaultConfig *Config = &Config{
DirectoryPath: "",
}
type Library struct {
ctx context.Context
conf *Config
}
func NewLibrary(conf *Config) (*Library, error) {
if conf == nil {
return nil, fmt.Errorf("nil config for library")
}
if err := conf.Validate(); err != nil {
return nil, fmt.Errorf("invalid library config %s\n%w", conf, err)
}
return &Library{
conf: conf,
}, nil
}
func (l *Library) Init(ctx context.Context) error {
l.ctx = ctx
return nil
}
func (l *Library) GetDir() (string, error) {
return l.conf.DirectoryPath, nil
}