+
+// FuncName returns the full name of a given function object
+func FuncName(i interface{}) string {
+ return runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()
+}
+
+// ShortFuncName returns the name only of a given function object
+func ShortFuncName(i interface{}) string {
+ return strings.TrimPrefix(runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name(), "main.(*View).")
+}
+
+// ReplaceHome takes a path as input and replaces ~ at the start of the path with the user's
+// home directory. Does nothing if the path does not start with '~'.
+func ReplaceHome(path string) string {
+ if !strings.HasPrefix(path, "~") {
+ return path
+ }
+
+ home, err := homedir.Dir()
+ if err != nil {
+ messenger.Error("Could not find home directory: ", err)
+ return path
+ }
+ return strings.Replace(path, "~", home, 1)
+}
+
+// GetPath returns a filename without everything following a `:`
+// This is used for opening files like util.go:10:5 to specify a line and column
+func GetPath(path string) string {
+ if strings.Contains(path, ":") {
+ path = strings.Split(path, ":")[0]
+ }
+ return path
+}