initial commit
This commit is contained in:
39
path-helper.go
Normal file
39
path-helper.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
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 ""
|
||||
}
|
Reference in New Issue
Block a user