From 11d792e6a902d683efd739ea015c80c5b735f0e1 Mon Sep 17 00:00:00 2001 From: mzz <2017@duck.com> Date: Sun, 14 May 2023 21:49:22 +0800 Subject: [PATCH] patch: search geodata at same dir with config first (#84) --- common/assets/assets.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/common/assets/assets.go b/common/assets/assets.go index 55ba5b2..8c5abad 100644 --- a/common/assets/assets.go +++ b/common/assets/assets.go @@ -70,13 +70,13 @@ func (c *LocationFinder) GetLocationAsset(log *logrus.Logger, filename string) ( // Search dirs. var searchDirs []string folder := "dae" - location := os.Getenv("DAE_LOCATION_ASSET") // check if DAE_LOCATION_ASSET is set + location := os.Getenv("DAE_LOCATION_ASSET") if location != "" { // add DAE_LOCATION_ASSET to search path - searchDirs = []string{ - location, - } + searchDirs = append(searchDirs, location) + // add /etc/dae to search path + searchDirs = append(searchDirs, c.externDirs...) // additional paths for non windows platforms if runtime.GOOS != "windows" { searchDirs = append( @@ -87,15 +87,16 @@ func (c *LocationFinder) GetLocationAsset(log *logrus.Logger, filename string) ( } searchDirs = append(searchDirs, c.externDirs...) } else { + // add /etc/dae to search path + searchDirs = append(searchDirs, c.externDirs...) if runtime.GOOS != "windows" { // Search XDG data directories on non windows platform - searchDirs = append([]string{xdg.DataHome}, xdg.DataDirs...) + searchDirs = append(searchDirs, xdg.DataHome) + searchDirs = append(searchDirs, xdg.DataDirs...) for i := range searchDirs { searchDirs[i] = filepath.Join(searchDirs[i], folder) } - searchDirs = append(searchDirs, c.externDirs...) } else { - searchDirs = append([]string{}, c.externDirs...) // fallback to the old behavior of using only current dir on Windows pwd := "./" if absPath, e := filepath.Abs(pwd); e == nil {