From f64dd9f191dff341b4eb430d7bacc44a3db9a279 Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期五, 04 三月 2022 10:12:45 +0800
Subject: [PATCH] fix nil

---
 extend/util/util.go |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/extend/util/util.go b/extend/util/util.go
index 5e2b118..3887458 100644
--- a/extend/util/util.go
+++ b/extend/util/util.go
@@ -8,6 +8,9 @@
 	"encoding/hex"
 	"fmt"
 	"math/rand"
+	"os"
+	"os/exec"
+	"path/filepath"
 	"strconv"
 	"strings"
 	"time"
@@ -82,4 +85,17 @@
 		return max
 	}
 	return rand.Intn(max-min) + min
+}
+
+
+func GetAppRootPath() string {
+	file,err:= exec.LookPath(os.Args[0])
+	if err != nil {
+		return ""
+	}
+	p, err := filepath.Abs(file)
+	if err != nil {
+		return ""
+	}
+	return filepath.Dir(p)
 }
\ No newline at end of file

--
Gitblit v1.8.0