Files
ddns-updater/internal/data/memory.go
Quentin McGaw bcbf0938c1 chore(lint): add revive linter and fix issues
- Export returned struct types
- Do not export interfaces for other packages to use
2022-08-28 22:18:19 +00:00

26 lines
504 B
Go

package data
import (
"fmt"
"github.com/qdm12/ddns-updater/internal/records"
)
func (db *Database) Select(id int) (record records.Record, err error) {
db.RLock()
defer db.RUnlock()
if id < 0 {
return record, fmt.Errorf("id %d cannot be lower than 0", id)
}
if id > len(db.data)-1 {
return record, fmt.Errorf("no record config found for id %d", id)
}
return db.data[id], nil
}
func (db *Database) SelectAll() (records []records.Record) {
db.RLock()
defer db.RUnlock()
return db.data
}