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)) }