all repos — searchix @ 0e24d9cde2f9a9e94315fa463d6503ddd64255c2

Search engine for NixOS, nix-darwin, home-manager and NUR users

refactor: reduce use of pointers in particular, Source can no longer be nil. Instantiate a Source with an Importer of All instead

Alan Pearce
commit

0e24d9cde2f9a9e94315fa463d6503ddd64255c2

parent

05838942b9468dd1efb6d295a206730fa82264c0

1 file changed, 7 insertions(+), 5 deletions(-)

changed files
M internal/config/structs.gointernal/config/structs.go
@@ -12,9 +12,9 @@ "github.com/creasty/defaults"
) type Config struct { - DataPath string `comment:"Path to store index data."` - Web *Web `comment:"Settings for the web server"` - Importer *Importer `comment:"Settings for the import job"` + DataPath string `comment:"Path to store index data."` + Web Web `comment:"Settings for the web server"` + Importer Importer `comment:"Settings for the import job"` } type Web struct {
@@ -31,7 +31,7 @@ SearchTimeout Duration `comment:"Timeout for search requests"`
} type Importer struct { - Sources map[string]*Source + Sources map[string]Source LowMemory bool `comment:"Use less memory at the expense of import performance"` BatchSize int `comment:"Number of items to process in each batch (affects memory usage)."` Timeout Duration `comment:"Abort fetch and import process for all jobs if it takes longer than this value."`
@@ -67,12 +67,14 @@ Enable bool `comment:"Enable searching for manpages"`
Path string `comment:"Path to the manpage-urls.json file from repository root"` } -func (source *Source) String() string { +func (source Source) String() string { switch source.Importer { case Options: return source.Name + " " + source.Importer.String() case Packages: return source.Name + case All: + return "All" default: return fmt.Sprintf("Source(%s)", source.Name) }