dati

A Go library/binary to parse & execute data against template langauges.
git clone git://src.gearsix.net/dati
Log | Files | Refs | Atom | README | LICENSE

commit 63a84422b418797f834a914bf8af415b0ae88fca
parent 68ba018e9ca48705fb28466b378491fa1365bc94
Author: gearsix <gearsix@tuta.io>
Date:   Thu,  4 Mar 2021 18:19:51 +0000

added MergeData(), started work on GenerateSuperData

Diffstat:
Msrc/data.go | 33+++++++++++++++++++++++++++++++--
1 file changed, 31 insertions(+), 2 deletions(-)

diff --git a/src/data.go b/src/data.go @@ -162,4 +162,33 @@ func sortFileData(data map[string]Data, order string) []Data { return sorted } - -\ No newline at end of file + +// GenerateSuperData TODO +func GenerateSuperData(datakey string, d []Data, global ...Data) (superd Data) { + if len(datakey) == 0 { + datakey = "data" + } + superd = MergeData(global...) + + if superd[datakey] != nil { + warn("global data has a key matching the datakey ('%s')\n", + "this value of this key will be overwritten") + } + superd[datakey] = d + return +} + + // MergeData TODO + func MergeData(data ...Data) Data { + merged := make(Data) + for _, d := range data { + for k, v := range d { + if merged[k] == nil { + merged[k] = v + } else { + warn("merge conflict for data key '%s'\n", k) + } + } + } + return merged + } +\ No newline at end of file