From abbe18314537935e1680af14d73657085543c249 Mon Sep 17 00:00:00 2001 From: stephenmk Date: Sat, 28 Jan 2023 18:39:08 -0600 Subject: [PATCH] Simplify logic for `index.json` struct --- common.go | 1 + enamdict.go | 2 -- epwing.go | 9 +++------ frequency.go | 9 +++------ jmdict.go | 1 - jmdict_forms.go | 1 - kanjidic.go | 2 -- rikai.go | 9 +++------ 8 files changed, 10 insertions(+), 24 deletions(-) diff --git a/common.go b/common.go index 9d6b2aa..613a255 100644 --- a/common.go +++ b/common.go @@ -214,6 +214,7 @@ func writeDb(outputPath string, index dbIndex, recordData map[string]dbRecordLis } } + index.setDefaults() bytes, err := marshalJSON(index, pretty) if err != nil { return err diff --git a/enamdict.go b/enamdict.go index e0c1cb0..78b886d 100644 --- a/enamdict.go +++ b/enamdict.go @@ -105,10 +105,8 @@ func jmnedictExportDb(inputPath, outputPath, language, title string, stride int, Title: title, Revision: "jmnedict1", Sequenced: true, - Description: "", Attribution: edrdgAttribution, } - index.setDefaults() return writeDb( outputPath, diff --git a/epwing.go b/epwing.go index 83b54b8..c7b2136 100644 --- a/epwing.go +++ b/epwing.go @@ -102,13 +102,10 @@ func epwingExportDb(inputPath, outputPath, language, title string, stride int, p } index := dbIndex{ - Title: title, - Revision: strings.Join(revisions, ";"), - Sequenced: true, - Description: "", - Attribution: "", + Title: title, + Revision: strings.Join(revisions, ";"), + Sequenced: true, } - index.setDefaults() return writeDb( outputPath, diff --git a/frequency.go b/frequency.go index 5d9f06a..310856c 100644 --- a/frequency.go +++ b/frequency.go @@ -56,13 +56,10 @@ func frequncyExportDb(inputPath, outputPath, language, title string, stride int, } index := dbIndex{ - Title: title, - Revision: "frequency1", - Sequenced: false, - Description: "", - Attribution: "", + Title: title, + Revision: "frequency1", + Sequenced: false, } - index.setDefaults() return writeDb( outputPath, diff --git a/jmdict.go b/jmdict.go index 4c54db6..746f7a0 100644 --- a/jmdict.go +++ b/jmdict.go @@ -238,7 +238,6 @@ func jmdExportDb(inputPath string, outputPath string, languageName string, title Sequenced: true, Attribution: edrdgAttribution, } - index.setDefaults() return writeDb( outputPath, diff --git a/jmdict_forms.go b/jmdict_forms.go index 4964233..59df010 100644 --- a/jmdict_forms.go +++ b/jmdict_forms.go @@ -254,7 +254,6 @@ func formsExportDb(inputPath, outputPath, languageName, title string, stride int Sequenced: true, Attribution: edrdgAttribution, } - index.setDefaults() return writeDb( outputPath, diff --git a/kanjidic.go b/kanjidic.go index e1c42d9..5474aed 100644 --- a/kanjidic.go +++ b/kanjidic.go @@ -163,10 +163,8 @@ func kanjidicExportDb(inputPath, outputPath, language, title string, stride int, Title: title, Revision: "kanjidic2", Sequenced: false, - Description: "", Attribution: edrdgAttribution, } - index.setDefaults() return writeDb( outputPath, diff --git a/rikai.go b/rikai.go index f3b6b12..bfc5307 100644 --- a/rikai.go +++ b/rikai.go @@ -153,13 +153,10 @@ func rikaiExportDb(inputPath, outputPath, language, title string, stride int, pr } index := dbIndex{ - Title: title, - Revision: "rikai2", - Sequenced: true, - Description: "", - Attribution: "", + Title: title, + Revision: "rikai2", + Sequenced: true, } - index.setDefaults() return writeDb( outputPath,