Initial import
This commit is contained in:
18
fs.go
Normal file
18
fs.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package sys
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func Rootify(path string) string {
|
||||
return filepath.Join(GetProjectRoot(), path)
|
||||
}
|
||||
|
||||
func GetProjectRoot() string {
|
||||
_, b, _, _ := runtime.Caller(0)
|
||||
// b is the absolute path to this specific .go file
|
||||
// 1st Dir() gets the folder containing the file
|
||||
// 2nd Dir() gets the parent of that folder
|
||||
return filepath.Dir(filepath.Dir(b))
|
||||
}
|
||||
Reference in New Issue
Block a user