update util

This commit is contained in:
alexchao26
2020-12-11 00:42:46 -05:00
parent bf32c8c51c
commit 37323d56a3
+10
View File
@@ -3,6 +3,7 @@ package util
import (
"io/ioutil"
"path"
"path/filepath"
"runtime"
"strings"
)
@@ -30,3 +31,12 @@ func ReadFile(pathFromCaller string) string {
strContent := string(content)
return strings.TrimRight(strContent, "\n")
}
// Dirname is a port of __dirname in node
func Dirname() string {
_, filename, _, ok := runtime.Caller(1)
if !ok {
panic("getting calling function")
}
return filepath.Dir(filename)
}