initial commit

This commit is contained in:
Arnaud Delcasse
2025-10-08 09:09:53 +02:00
commit efccea3f64
16 changed files with 2780 additions and 0 deletions

44
config.go Normal file
View File

@@ -0,0 +1,44 @@
package main
import (
"strings"
"github.com/spf13/viper"
)
func ReadConfig() (*viper.Viper, error) {
defaults := map[string]any{
"name": "COOPGO Saved Search Service",
"dev_env": false,
"storage": map[string]any{
"db": map[string]any{
"type": "mongodb",
"mongodb": map[string]any{
"host": "localhost",
"port": 27017,
"db_name": "coopgo_platform",
"collections": map[string]any{
"saved_searches": "saved_searches",
},
},
},
},
"services": map[string]any{
"grpc": map[string]any{
"enable": true,
"port": 8080,
},
},
}
v := viper.New()
for key, value := range defaults {
v.SetDefault(key, value)
}
v.SetConfigName("config")
v.AddConfigPath(".")
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
v.AutomaticEnv()
err := v.ReadInConfig()
return v, err
}