Skip to content

Commit 8ef9006

Browse files
Fixed config not found if app not called from installed location
1 parent 5a3e19b commit 8ef9006

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

internal/config/config.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"fmt"
55
"log"
66
"net/url"
7+
"os"
8+
"path/filepath"
79
"strings"
810

911
"github.com/fsnotify/fsnotify"
@@ -162,6 +164,12 @@ func LoadConfig() {
162164
viper.AddConfigPath("/etc/docStreamer")
163165
viper.AddConfigPath("$HOME/.docStreamer")
164166

167+
ex, err := os.Executable()
168+
if err == nil {
169+
exePath := filepath.Dir(ex)
170+
viper.AddConfigPath(exePath)
171+
}
172+
165173
if err := viper.ReadInConfig(); err != nil {
166174
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
167175
log.Println("Config file not found, using defaults and environment variables.")

0 commit comments

Comments
 (0)