package ledger import ( "github.com/howeyc/ledger" ) type File string func NewFile(p string) (File, error) { f := File(p) _, err := f.Deltas() return f, err } func (file File) Deltas(like ...Like) ([]Delta, error) { transactions, err := file.transactions() if err != nil { return nil, err } result := make([]Delta, 0, len(transactions)*2) for _, transaction := range transactions { for _, delta := range newDeltas(transaction) { if !likes(like).all(delta) { continue } result = append(result, delta) } } return result, nil } func (file File) transactions() ([]*ledger.Transaction, error) { return ledger.ParseLedgerFile(string(file)) }