|
@@ -45,14 +45,16 @@ func NormalizeEnvName(name string) string {
|
|
|
return strings.Replace(strings.ToUpper(strings.TrimSpace(name)), ".", "_", -1)
|
|
return strings.Replace(strings.ToUpper(strings.TrimSpace(name)), ".", "_", -1)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func getExecutableDir() string {
|
|
|
|
|
+ exec, err := os.Executable()
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return ""
|
|
|
|
|
+ }
|
|
|
|
|
+ return filepath.Dir(exec)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func GetAssetLocation(file string) string {
|
|
func GetAssetLocation(file string) string {
|
|
|
const name = "v2ray.location.asset"
|
|
const name = "v2ray.location.asset"
|
|
|
- assetPath := EnvFlag{Name: name, AltName: NormalizeEnvName(name)}.GetValue(func() string {
|
|
|
|
|
- exec, err := os.Executable()
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- return ""
|
|
|
|
|
- }
|
|
|
|
|
- return filepath.Dir(exec)
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ assetPath := EnvFlag{Name: name, AltName: NormalizeEnvName(name)}.GetValue(getExecutableDir)
|
|
|
return filepath.Join(assetPath, file)
|
|
return filepath.Join(assetPath, file)
|
|
|
}
|
|
}
|