From 830ccb6660788c4b78e21f28eee0e354928079e2 Mon Sep 17 00:00:00 2001 From: skyblue Date: Mon, 9 Dec 2013 13:30:19 +0800 Subject: [PATCH] initial utils dir --- utils/file.go | 11 +++++++++++ utils/file_test.go | 13 +++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 utils/file.go create mode 100644 utils/file_test.go 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) +}