diff --git a/utils/file.go b/utils/file.go new file mode 100644 index 00000000..a135a81d --- /dev/null +++ b/utils/file.go @@ -0,0 +1,11 @@ +package utils + +import ( + "os" + "path/filepath" +) + +func SelfPath() string { + path, _ := filepath.Abs(os.Args[0]) + return path +} diff --git a/utils/file_test.go b/utils/file_test.go new file mode 100644 index 00000000..da3b1324 --- /dev/null +++ b/utils/file_test.go @@ -0,0 +1,13 @@ +package utils + +import ( + "testing" +) + +func TestSelfPath(t *testing.T) { + path := SelfPath() + if path == "" { + t.Error("path cannot be empty") + } + t.Logf("SelfPath: %s", path) +}