Settings package

Is there a package that makes handling application settings easier (or less repetitive)? I am thinking about something like this (pseudo code):

  setting := NewJSONSettings('/home/user/setting.json')
  setting.AddSettingsCategory('database-connection')
  setting.AddSetting('database-connection','server','192.168.1.1')
  setting.AddSetting('database-connection','username','me')
  setting.AddSetting('database-connection','password','mypassword')
  setting.AddSettingsCategory('preferences')
  setting.AddSetting('preferences','dark-theme','true')
  err:=setting.Save()

And then for loading, maybe something like:

  settings := Settings.Load('home/user/settings.json')
  fmt.Println(settings.preferences.dark-theme)

What I want is just to hide all the “complexity” involved in creating the json file and structs and all that. And I guess it’s not that complex code, just repetitive if you are writing many small applications. Is there a package for something like this?

Maybe projects like this:

So that your JSON models are not “stringly typed.” If you’re OK with accessing object properties with strings everywhere, you could just unmarshal your config into a map[string]interface{}.

1 Like

Thank you, I will check this projects out…

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.