mirror of
https://github.com/hacdias/webdav.git
synced 2026-09-25 20:51:53 +08:00
feat: add executable's directory as config path
This commit is contained in:
@@ -3,6 +3,7 @@ package lib
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -53,6 +54,10 @@ func ParseConfig(filename string, flags *pflag.FlagSet) (*Config, error) {
|
|||||||
// Configuration file settings
|
// Configuration file settings
|
||||||
v.AddConfigPath(".")
|
v.AddConfigPath(".")
|
||||||
v.AddConfigPath("/etc/webdav/")
|
v.AddConfigPath("/etc/webdav/")
|
||||||
|
if path, err := os.Executable(); err == nil {
|
||||||
|
v.AddConfigPath(filepath.Dir(path))
|
||||||
|
}
|
||||||
|
|
||||||
v.SetConfigName("config")
|
v.SetConfigName("config")
|
||||||
if filename != "" {
|
if filename != "" {
|
||||||
v.SetConfigFile(filename)
|
v.SetConfigFile(filename)
|
||||||
|
|||||||
Reference in New Issue
Block a user