mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
Removed (almost) all remaining init()
This commit is contained in:
parent
5d2a7b1db1
commit
23e38ec82f
5 changed files with 34 additions and 23 deletions
|
@ -33,6 +33,20 @@ func LoadFromFlags() {
|
|||
l.Load(Sonic)
|
||||
}
|
||||
|
||||
func LoadFromEnv() {
|
||||
port := os.Getenv("PORT")
|
||||
if port != "" {
|
||||
Sonic.Port = port
|
||||
}
|
||||
l := &multiconfig.EnvironmentLoader{}
|
||||
l.Load(Sonic)
|
||||
}
|
||||
|
||||
func LoadFromTags() {
|
||||
l := &multiconfig.TagLoader{}
|
||||
l.Load(Sonic)
|
||||
}
|
||||
|
||||
func LoadFromFile(tomlFile string) {
|
||||
l := &multiconfig.TOMLLoader{Path: tomlFile}
|
||||
err := l.Load(Sonic)
|
||||
|
@ -47,11 +61,13 @@ func LoadFromLocalFile() {
|
|||
}
|
||||
}
|
||||
|
||||
func Load() {
|
||||
LoadFromLocalFile()
|
||||
LoadFromEnv()
|
||||
LoadFromFlags()
|
||||
}
|
||||
|
||||
func init() {
|
||||
Sonic = new(sonic)
|
||||
var l multiconfig.Loader
|
||||
l = &multiconfig.TagLoader{}
|
||||
l.Load(Sonic)
|
||||
l = &multiconfig.EnvironmentLoader{}
|
||||
l.Load(Sonic)
|
||||
LoadFromTags()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue