/go-recutils

Go wrapper for recutils

Primary LanguageGoGNU General Public License v3.0GPL-3.0

go-recutils

Go wrapper for interacting with recutils with some niceties for the modern world like providing structured return values and errors.

Usage

See the example folder to run sample code that tests all currently-implemented functions.

csv2rec, mdb2rec, rec2csv

TODO; mdb2rec may not be implemented.

recinf

recinfo, err = recfile.Inf()

recsel

// type SelectionParams struct {
// 	Type       string
// 	Expression string
// 	Quick      string
// 	Number     []int
// 	Random     int
// 	Join       string
// }

params = rec.SelectionParams{Type: "books", Expression: "Title='Junkyard Jam Band'"}
options = rec.DefaultOptions
recordSet = recfile.Sel(params, options)
recordSeterror = recordSet.Error

recfix

// type OptionFlags struct {
//	Force           bool
//	NoExternal      bool
//	NoAuto          bool
//	CaseInsensitive bool
//	Unique          bool
// }

options = rec.OptionFlags{CaseInsensitive: true}
newRecordSet = recordSet.Fix(rec.Check, rec.DefaultOptions)
newRecfile = recfile.Fix(rec.Check, rec.DefaultOptions)
recfileError = newRecfile.Error

recdel

newRecordSet = recordSet.Del(params, rec.DefaultOptions, rec.Remove)
newRecfile = recfile.Del(params, options, rec.Comment) 

recins

anotherRecordSet = recordSet.Ins(newRecordSet, params, options)
newRecfile = recfile.Ins(newRecordSet, params, options)

recset

fields = []string{"Status"}
action = rec.FieldAction{ActionType: "SetAdd", ActionValue: "Read"}
newRecfile := recFile.Set(fields, action, params, options)

recfmt

templateOutput, err = recordSet.Fmt("{{Title}}: {{Subtitle}}", false)
template2Output, err = recordSet.Fmt("template.txt", true)