mirror of
https://github.com/Threnklyn/advent-of-code-go.git
synced 2026-06-06 04:08:27 +02:00
update util
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user