Skip to content

Commit

Permalink
Fix easy config
Browse files Browse the repository at this point in the history
  • Loading branch information
debug-ing committed Dec 11, 2024
1 parent 3008c46 commit 7688aee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"flag"
"log"

"github.com/debug-ing/radio-music/config"
Expand All @@ -11,7 +12,9 @@ import (
)

func main() {
config := config.LoadConfig()
configPath := flag.String("config", "config.toml", "config file")
flag.Parse()
config := config.LoadConfig(*configPath)
client := internal.NewClient()
go internal.StartStream(config.App.Folder, client)
r := gin.Default()
Expand Down
4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ type Config struct {
var configPublic *Config
var once sync.Once

func LoadConfig() (config *Config) {
func LoadConfig(address string) (config *Config) {
once.Do(func() {
viper.SetConfigFile("config/config.toml")
viper.SetConfigFile(address)
if err := viper.ReadInConfig(); err != nil {
panic(err)
}
Expand Down

0 comments on commit 7688aee

Please sign in to comment.