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, 10 insertions(+), 5 deletions(-)

changed files
M internal/config/default.gointernal/config/default.go
@@ -2,6 +2,7 @@ package config
import ( "strconv" + "strings" "time" "github.com/pelletier/go-toml/v2"
@@ -22,7 +23,7 @@ const maxAge = (1 * 365 * 24 * time.Hour)
var DefaultConfig = Config{ DataPath: "./data", - Web: &Web{ + Web: Web{ ListenAddress: "localhost", Port: 3000, BaseURL: mustURL("http://localhost:3000"),
@@ -50,12 +51,12 @@ },
LogRequests: true, SearchTimeout: Duration{1 * time.Second}, }, - Importer: &Importer{ + Importer: Importer{ LowMemory: false, BatchSize: 10_000, Timeout: Duration{30 * time.Minute}, UpdateAt: mustLocalTime("03:00:00"), - Sources: map[string]*Source{ + Sources: map[string]Source{ "nixos": { Name: "NixOS", Order: 0,
@@ -170,10 +171,14 @@ },
} func GetDefaultConfig() string { - out, err := toml.Marshal(&DefaultConfig) + var out strings.Builder + + enc := toml.NewEncoder(&out) + + err := enc.Encode(DefaultConfig) if err != nil { panic("could not read default configuration") } - return string(out) + return out.String() }