40 lines
817 B
Go
40 lines
817 B
Go
package config
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
// should return the dir path of the exe file
|
|
func getConfigContainerBesidesExe() string {
|
|
if os.Getenv("DEBUG") == "true" {
|
|
path, err := os.Getwd()
|
|
if err != nil {
|
|
log.Fatal("Failed to Get Work Dir", err)
|
|
}
|
|
return path
|
|
} else {
|
|
executablePath, err := os.Executable()
|
|
if err != nil {
|
|
log.Fatal("Failed to Get Executable Path", err)
|
|
}
|
|
executableDir := filepath.Dir(executablePath)
|
|
return executableDir
|
|
}
|
|
}
|
|
|
|
func getConfigContainerUserConfig(appName string) string {
|
|
dir, err := os.UserConfigDir()
|
|
if err != nil {
|
|
log.Fatal("Failed to Get User Config Dir", err)
|
|
}
|
|
dir = filepath.Join(dir, appName)
|
|
return dir
|
|
}
|
|
|
|
func getConfigContainerSystemConfig(appName string) string {
|
|
log.Fatal("Error, not Implemented yet")
|
|
return ""
|
|
}
|